Ejemplo n.º 1
0
        private PropertyDescriptor[] GetDescriptors(object converter)
        {
            IComponentDescriptor componentDescriptor = GetComponentDescriptor();

            if (componentDescriptor != null)
            {
                PropertyDescriptor[] properties = componentDescriptor.GetProperties(this, converter);
                return(properties);
            }
            else
            {
                if (Component.GetType().IsScript())
                {
                    FieldInfo[] serializableFields = Component.GetType().GetSerializableFields();
                    return(serializableFields.Select(f => new PropertyDescriptor(f.Name, Component, f, f)).ToArray());
                }
                else
                {
                    PropertyInfo[] properties = Component.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(p => p.CanRead && p.CanWrite).ToArray();
                    return(properties.Select(p => new PropertyDescriptor(p.Name, Component, p, p)).ToArray());
                }
            }
        }