本文整理汇总了C#中MemberInfo.IsDefined方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.IsDefined方法的具体用法?C# MemberInfo.IsDefined怎么用?C# MemberInfo.IsDefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberInfo
的用法示例。
在下文中一共展示了MemberInfo.IsDefined方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: isCompatibleType
private bool isCompatibleType( MemberInfo member, Type type, bool allowStringType )
{
if( member.IsDefined( typeof( HideInInspector ), true ) )
return false;
if( member is FieldInfo )
{
var fieldInfo = (FieldInfo)member;
if( type.IsAssignableFrom( fieldInfo.FieldType ) )
return true;
if( allowStringType && fieldInfo.FieldType == typeof( string ) )
return true;
if( isNumericConversion( fieldInfo.FieldType, type ) )
{
return true;
}
}
else if( member is PropertyInfo )
{
var propertyInfo = (PropertyInfo)member;
if( type.IsAssignableFrom( propertyInfo.PropertyType ) )
return true;
if( allowStringType && propertyInfo.PropertyType == typeof( string ) )
return true;
if( isNumericConversion( propertyInfo.PropertyType, type ) )
{
return true;
}
}
return false;
}
示例2: ShowMember
bool ShowMember (MemberInfo mi)
{
if (mi.MemberType == MemberTypes.Constructor && ((MethodBase) mi).IsStatic)
return false;
if (options.ShowPrivate)
return true;
if (options.FilterObsolete && mi.IsDefined (typeof (ObsoleteAttribute), false))
return false;
switch (mi.MemberType) {
case MemberTypes.Constructor:
case MemberTypes.Method:
MethodBase mb = mi as MethodBase;
if (mb.IsFamily || mb.IsPublic || mb.IsFamilyOrAssembly)
return true;
if (MethodIsExplicitIfaceImpl (mb))
return true;
return false;
case MemberTypes.Field:
FieldInfo fi = mi as FieldInfo;
if (fi.IsFamily || fi.IsPublic || fi.IsFamilyOrAssembly)
return true;
return false;
case MemberTypes.NestedType:
case MemberTypes.TypeInfo:
Type t = mi as Type;
switch (t.Attributes & TypeAttributes.VisibilityMask){
case TypeAttributes.Public:
case TypeAttributes.NestedPublic:
case TypeAttributes.NestedFamily:
case TypeAttributes.NestedFamORAssem:
return true;
}
return false;
}
// What am I !!!
return true;
}