Пример #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ItemInfo"/> class.
            /// </summary>
            /// <param name="info">The reflection information.</param>
            /// <param name="attributes">The attributes.</param>
            public ItemInfo(MemberInfo info, object[] attributes)
            {
                Info              = info;
                Order             = (EditorOrderAttribute)attributes.FirstOrDefault(x => x is EditorOrderAttribute);
                Display           = (EditorDisplayAttribute)attributes.FirstOrDefault(x => x is EditorDisplayAttribute);
                Tooltip           = (TooltipAttribute)attributes.FirstOrDefault(x => x is TooltipAttribute);
                CustomEditor      = (CustomEditorAttribute)attributes.FirstOrDefault(x => x is CustomEditorAttribute);
                CustomEditorAlias = (CustomEditorAliasAttribute)attributes.FirstOrDefault(x => x is CustomEditorAliasAttribute);
                Space             = (SpaceAttribute)attributes.FirstOrDefault(x => x is SpaceAttribute);
                Header            = (HeaderAttribute)attributes.FirstOrDefault(x => x is HeaderAttribute);
                VisibleIf         = (VisibleIfAttribute)attributes.FirstOrDefault(x => x is VisibleIfAttribute);
                IsReadOnly        = attributes.FirstOrDefault(x => x is ReadOnlyAttribute) != null;
                ExpandGroups      = attributes.FirstOrDefault(x => x is ExpandGroupsAttribute) != null;

                if (!IsReadOnly && info is FieldInfo fieldInfo && fieldInfo.IsInitOnly)
                {
                    // Field declared with `readonly` keyword
                    IsReadOnly = true;
                }
                if (!IsReadOnly && info is PropertyInfo propertyInfo && !propertyInfo.CanWrite)
                {
                    // Property without a setter
                    IsReadOnly = true;
                }
                if (Display?.Name != null)
                {
                    // Use name provided by the attribute
                    DisplayName = Display.Name;
                }
                else
                {
                    // Use filtered member name
                    DisplayName = CustomEditorsUtil.GetPropertyNameUI(info.Name);
                }
            }
Пример #2
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ItemInfo"/> class.
            /// </summary>
            /// <param name="info">The reflection information.</param>
            /// <param name="attributes">The attributes.</param>
            public ItemInfo(MemberInfo info, object[] attributes)
            {
                Info              = info;
                Order             = (EditorOrderAttribute)attributes.FirstOrDefault(x => x is EditorOrderAttribute);
                Display           = (EditorDisplayAttribute)attributes.FirstOrDefault(x => x is EditorDisplayAttribute);
                Tooltip           = (TooltipAttribute)attributes.FirstOrDefault(x => x is TooltipAttribute);
                CustomEditor      = (CustomEditorAttribute)attributes.FirstOrDefault(x => x is CustomEditorAttribute);
                CustomEditorAlias = (CustomEditorAliasAttribute)attributes.FirstOrDefault(x => x is CustomEditorAliasAttribute);
                Space             = (SpaceAttribute)attributes.FirstOrDefault(x => x is SpaceAttribute);
                Header            = (HeaderAttribute)attributes.FirstOrDefault(x => x is HeaderAttribute);
                VisibleIf         = (VisibleIfAttribute)attributes.FirstOrDefault(x => x is VisibleIfAttribute);
                IsReadOnly        = attributes.FirstOrDefault(x => x is ReadOnlyAttribute) != null;
                ExpandGroups      = attributes.FirstOrDefault(x => x is ExpandGroupsAttribute) != null;

                if (Display?.Name != null)
                {
                    // Use name provided by the attribute
                    DisplayName = Display.Name;
                }
                else
                {
                    // Use filtered member name
                    DisplayName = CustomEditorsUtil.GetPropertyNameUI(info.Name);
                }
            }
Пример #3
0
 public GraphParameterData(GraphParameter parameter, string name, bool isPublic, Type type, Attribute[] attributes, object tag)
 {
     Parameter   = parameter;
     IsPublic    = isPublic;
     Type        = type;
     Tag         = tag;
     Attributes  = attributes;
     Order       = (EditorOrderAttribute)Attributes.FirstOrDefault(x => x is EditorOrderAttribute);
     Display     = (EditorDisplayAttribute)Attributes.FirstOrDefault(x => x is EditorDisplayAttribute);
     Tooltip     = (TooltipAttribute)Attributes.FirstOrDefault(x => x is TooltipAttribute);
     Space       = (SpaceAttribute)Attributes.FirstOrDefault(x => x is SpaceAttribute);
     Header      = (HeaderAttribute)Attributes.FirstOrDefault(x => x is HeaderAttribute);
     DisplayName = Display?.Name ?? name ?? parameter.Name;
 }
Пример #4
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ItemInfo"/> class.
            /// </summary>
            /// <param name="info">The reflection information.</param>
            /// <param name="attributes">The attributes.</param>
            public ItemInfo(ScriptMemberInfo info, object[] attributes)
            {
                Info              = info;
                Order             = (EditorOrderAttribute)attributes.FirstOrDefault(x => x is EditorOrderAttribute);
                Display           = (EditorDisplayAttribute)attributes.FirstOrDefault(x => x is EditorDisplayAttribute);
                Tooltip           = (TooltipAttribute)attributes.FirstOrDefault(x => x is TooltipAttribute);
                CustomEditor      = (CustomEditorAttribute)attributes.FirstOrDefault(x => x is CustomEditorAttribute);
                CustomEditorAlias = (CustomEditorAliasAttribute)attributes.FirstOrDefault(x => x is CustomEditorAliasAttribute);
                Space             = (SpaceAttribute)attributes.FirstOrDefault(x => x is SpaceAttribute);
                Header            = (HeaderAttribute)attributes.FirstOrDefault(x => x is HeaderAttribute);
                VisibleIf         = (VisibleIfAttribute)attributes.FirstOrDefault(x => x is VisibleIfAttribute);
                IsReadOnly        = attributes.FirstOrDefault(x => x is ReadOnlyAttribute) != null;
                ExpandGroups      = attributes.FirstOrDefault(x => x is ExpandGroupsAttribute) != null;

                IsReadOnly |= !info.HasSet;
                DisplayName = Display?.Name ?? CustomEditorsUtil.GetPropertyNameUI(info.Name);
            }
Пример #5
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ItemInfo"/> class.
            /// </summary>
            /// <param name="info">The reflection information.</param>
            /// <param name="attributes">The attributes.</param>
            public ItemInfo(ScriptMemberInfo info, object[] attributes)
            {
                Info              = info;
                Order             = (EditorOrderAttribute)attributes.FirstOrDefault(x => x is EditorOrderAttribute);
                Display           = (EditorDisplayAttribute)attributes.FirstOrDefault(x => x is EditorDisplayAttribute);
                CustomEditor      = (CustomEditorAttribute)attributes.FirstOrDefault(x => x is CustomEditorAttribute);
                CustomEditorAlias = (CustomEditorAliasAttribute)attributes.FirstOrDefault(x => x is CustomEditorAliasAttribute);
                Space             = (SpaceAttribute)attributes.FirstOrDefault(x => x is SpaceAttribute);
                Header            = (HeaderAttribute)attributes.FirstOrDefault(x => x is HeaderAttribute);
                VisibleIf         = (VisibleIfAttribute)attributes.FirstOrDefault(x => x is VisibleIfAttribute);
                IsReadOnly        = attributes.FirstOrDefault(x => x is ReadOnlyAttribute) != null;
                ExpandGroups      = attributes.FirstOrDefault(x => x is ExpandGroupsAttribute) != null;

                IsReadOnly |= !info.HasSet;
                DisplayName = Display?.Name ?? CustomEditorsUtil.GetPropertyNameUI(info.Name);
                var editor = Editor.Instance;

                TooltipText   = editor.CodeDocs.GetTooltip(info, attributes);
                _membersOrder = editor.Options.Options.General.ScriptMembersOrder;
            }