Пример #1
0
        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;
        }
Пример #2
0
 private bool EditorMemberAffectsOthers(MemberInfo info)
 {
     EditorHintFlagsAttribute flagsAttrib = info.GetAttributesCached<EditorHintFlagsAttribute>().FirstOrDefault();
     return this.ShowNonPublic || (flagsAttrib != null && (flagsAttrib.Flags & MemberFlags.AffectsOthers) != MemberFlags.None);
 }