本文整理汇总了C#中PropertyInfo.GetCustomAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.GetCustomAttributes方法的具体用法?C# PropertyInfo.GetCustomAttributes怎么用?C# PropertyInfo.GetCustomAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.GetCustomAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildPropertyString
public static string BuildPropertyString(ref PropertyInfo field)
{
string str = "no help";
object[] customAttributes = field.GetCustomAttributes(true);
for (int i = 0; i < (int)customAttributes.Length; i++)
{
object obj = customAttributes[i];
if (obj is ConsoleSystem.Help)
{
str = (obj as ConsoleSystem.Help).helpDescription;
}
}
return string.Concat(field.Name, " : ", str);
}
示例2: GetExplicitAttributes
internal static IEnumerable<Attribute> GetExplicitAttributes( PropertyInfo propertyDescriptor )
{
var list = new List<Attribute>( propertyDescriptor.GetCustomAttributes<Attribute>( true ) );
var enumerable = propertyDescriptor.PropertyType.GetTypeInfo().GetCustomAttributes<Attribute>();
foreach ( var current in enumerable )
{
for ( int i = list.Count - 1; i >= 0; i-- )
{
if ( object.ReferenceEquals( current, list[i] ) )
{
list.RemoveAt( i );
}
}
}
return list;
}
示例3: FilterProperty
public FilterProperty( PropertyInfo info, AGATFilter filterInstance )
{
_info = info;
object[] attributes = info.GetCustomAttributes( typeof( FloatPropertyRange ), true );
if( attributes.Length == 0 )
{
attributes = info.GetCustomAttributes( typeof( ToggleGroupProperty ), true );
if( attributes.Length == 1 )
{
_isGroupToggle = true;
}
}
else
{
_range = ( FloatPropertyRange )attributes[ 0 ];
}
object val = info.GetValue( filterInstance, null );
if( val is float )
{
_currentValue = ( float )val;
_labelString = _info.Name + ": " + _currentValue.ToString("0.00");
}
else if( val is double )
{
_currentValue = ( float )( ( double )val );
_labelString = _info.Name + ": " + _currentValue.ToString("0.00");
}
else if( val is bool )
{
GroupToggleState = ( bool )val;
_labelString = _info.Name;
}
_filter = filterInstance;
}