FlatRedBall.Glue.GuiDisplay.PropertyGridMember.SetAttributes C# (CSharp) 메소드

SetAttributes() 공개 메소드

public SetAttributes ( object attributesInObjectArray ) : void
attributesInObjectArray object
리턴 void
        public void SetAttributes(object[] attributesInObjectArray)
        {
            Attributes.Clear();

            
            for (int i = 0; i < attributesInObjectArray.Length; i++)
            {
                Attributes.Add((Attribute)attributesInObjectArray[i]);
            }
        }

Usage Example

예제 #1
0
        private void UpdateProperties()
        {
            if (mInstance != null)
            {
                // This only removes
                // native members that
                // haven't been explicitly
                // added.  Explicitly-added
                // members may have TypeConverters
                // so we want to preserve those.
                ClearNonExplicitNativeMembers();

                PropertyInfo[] propertyInfos = mInstance.GetType().GetProperties(

                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty // I don't think we want to show static members in PropertyGrids
                    );

                foreach (PropertyInfo propertyInfo in propertyInfos)
                {
                    if (!mExcludedMembers.Contains(propertyInfo.Name) && !mCustomPropertyGridMembers.ContainsMember(propertyInfo.Name))
                    {
                        PropertyGridMember pgm = new PropertyGridMember();
                        pgm.Name = propertyInfo.Name;
                        pgm.Type = propertyInfo.PropertyType;

                        pgm.SetAttributes(propertyInfo.GetCustomAttributes(true));
                        pgm.IsReadOnly = propertyInfo.CanWrite == false;
                        // Does this thing have a type converter set on the property?
                        TypeConverterAttribute attrib =
                            (TypeConverterAttribute)Attribute.GetCustomAttribute(propertyInfo,
                                                                                 typeof(TypeConverterAttribute));
                        if (attrib != null)
                        {
                            TypeConverter converter =
                                (TypeConverter)Activator.CreateInstance(Type.GetType(attrib.ConverterTypeName),
                                                                        false);
                            pgm.TypeConverter = converter;
                        }

                        mNativePropertyGridMembers.Add(pgm);
                    }
                }

                FieldInfo[] fieldInfos = mInstance.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField);
                foreach (FieldInfo fieldInfo in fieldInfos)
                {
                    if (!mExcludedMembers.Contains(fieldInfo.Name) && !mCustomPropertyGridMembers.ContainsMember(fieldInfo.Name))
                    {
                        PropertyGridMember pgm = new PropertyGridMember()
                        {
                            Name = fieldInfo.Name,
                            Type = fieldInfo.FieldType
                        };

                        mNativePropertyGridMembers.Add(pgm);
                    }
                }
            }
        }
All Usage Examples Of FlatRedBall.Glue.GuiDisplay.PropertyGridMember::SetAttributes