コード例 #1
0
        public static Drawer CreateAttrDrawer(DrawerProperty property, DrawerAttribute attr)
        {
            if (attrDrawerDic.TryGetValue(attr.GetType(), out Type drawerType))
            {
                Drawer drawer = (Drawer)Activator.CreateInstance(drawerType);
                drawer.Attr     = attr;
                drawer.Property = property;

                return(drawer);
            }

            return(null);
        }
コード例 #2
0
        public static PropertyContentDrawer CreateCustomTypeDrawer(DrawerProperty property)
        {
            Type type = GetReallyDrawerType(property.ValueType);

            if (customTypeDrawerDic.TryGetValue(type, out Type drawerType))
            {
                PropertyContentDrawer drawer = (PropertyContentDrawer)Activator.CreateInstance(drawerType);
                drawer.Property = property;

                return(drawer);
            }

            return(null);
        }
コード例 #3
0
        private void InitField()
        {
            Type[] allTypes = DrawerUtility.GetAllBaseTypes(drawerObject.GetType());
            if (allTypes != null)
            {
                foreach (var type in allTypes)
                {
                    TypeDrawerProperty typeDrawerProperty = new TypeDrawerProperty()
                    {
                        type = type,
                    };

                    FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
                    foreach (var field in fields)
                    {
                        DrawerProperty drawerProperty = new DrawerProperty(drawerObject, field);
                        typeDrawerProperty.drawerProperties.Add(drawerProperty);
                    }

                    typeDrawerProperties.Add(typeDrawerProperty);
                }
            }
        }