当前位置: 首页>>代码示例>>C#>>正文


C# MemberInfo.GetAttributesCached方法代码示例

本文整理汇总了C#中System.Reflection.MemberInfo.GetAttributesCached方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.GetAttributesCached方法的具体用法?C# MemberInfo.GetAttributesCached怎么用?C# MemberInfo.GetAttributesCached使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.MemberInfo的用法示例。


在下文中一共展示了MemberInfo.GetAttributesCached方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EditorMemberPredicate

        private bool EditorMemberPredicate(MemberInfo info, bool showNonPublic)
        {
            PropertyInfo property = info as PropertyInfo;
            FieldInfo field = info as FieldInfo;
            EditorHintFlagsAttribute flagsAttrib = info.GetAttributesCached<EditorHintFlagsAttribute>().FirstOrDefault();

            // Accept all members in "Debug Mode", if not declared inside Duality itself
            if (showNonPublic && info.DeclaringType.Assembly != typeof(DualityApp).Assembly) return true;

            // Accept explicitly visible members
            if (flagsAttrib != null && (flagsAttrib.Flags & MemberFlags.Visible) != MemberFlags.None) return true;

            // Reject properties with non-public getters
            if (property != null)
            {
                MethodInfo getter = property.GetGetMethod(true);
                if (getter == null) return false;
                if (!getter.IsPublic) return false;
            }

            // Reject non-public fields
            if (field != null && !field.IsPublic) return false;

            // Reject even public fields of a Component - we don't want to encourage using them, since Duality basically works with Properties.
            if (field != null && typeof(Component).IsAssignableFrom(info.DeclaringType)) return false;

            // Reject explicitly invisible members
            if (flagsAttrib != null && (flagsAttrib.Flags & MemberFlags.Invisible) != MemberFlags.None) return false;

            return true;
        }
开发者ID:sinithwar,项目名称:duality,代码行数:31,代码来源:DualitorPropertyGrid.cs

示例2: EditorMemberAffectsOthers

 private bool EditorMemberAffectsOthers(MemberInfo info)
 {
     EditorHintFlagsAttribute flagsAttrib = info.GetAttributesCached<EditorHintFlagsAttribute>().FirstOrDefault();
     return this.ShowNonPublic || (flagsAttrib != null && (flagsAttrib.Flags & MemberFlags.AffectsOthers) != MemberFlags.None);
 }
开发者ID:sinithwar,项目名称:duality,代码行数:5,代码来源:DualitorPropertyGrid.cs


注:本文中的System.Reflection.MemberInfo.GetAttributesCached方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。