Example #1
0
        public static void Create(Editors editors, object component)
        {
            var componentType = component.GetType();

            var properties = componentType.GetProperties();

            for (var i = 0; i < properties.Length; i++)
            {
                var property = properties[i];

                var attributes = property.GetCustomAttributes(typeof(EditorAttribute), false);
                for (var a = 0; a < attributes.Length; a++)
                {
                    if (attributes[a] is EditorAttribute attribute)
                    {
                        var getter = GetGetter(property, component);
                        var setter = GetSetter(attribute.Setter, component, componentType) ?? GetSetter(property, component);

                        var index = 0;
                        if (!string.IsNullOrEmpty(attribute.IndexProperty))
                        {
                            index = (int)component.GetType().GetProperty(attribute.IndexProperty).GetGetMethod().Invoke(component, null);
                        }

                        editors.Create(attribute.Name, getter(), attribute.MinMax, setter, index);
                    }
                }
            }
        }