透过使用反映,您可以撷取由自订属性定义的资讯。
By using reflection, you can retrieve the information that was defined with custom attributes.
然后,您可以逐一查看阵列,以每项阵列元素的类型为基础来决定所要套用的属性,并且从属性物件撷取资讯。
You can then iterate over this array, determine what attributes were applied based on the type of each array element, and extract information from the attribute objects.
如果没有可以撷取资讯并加以执行的方法,那么定义自订属性并且将他们放置在您的原始程序码中实际上的价值不大。
The fact that you can define custom attributes and place them in your source code would be of little value without some way of retrieving that information and acting on it.
应用推荐