Exemplo n.º 1
0
        /// <summary>
        /// Gets style properties (attributes converted to style properties)
        /// </summary>
        /// <param name="type"></param>
        /// <param name="restrictToSerializableTypes"></param>
        /// <returns></returns>
        public static List <StyleProperty> GetStyleProperties(Type type, bool restrictToSerializableTypes = false)
        {
            var attributes = GetStyleAttributes(type);

            List <StyleProperty> list = new List <StyleProperty>();

            foreach (var attribute in attributes)
            {
                /* with "skinClass" style, the Type isn't required. Set it here */
                if (attribute.Name == "skinClass" /* && null == attribute.Type*/)
                {
                    attribute.Type    = typeof(string);
                    attribute.Default = null;
                }

                if (restrictToSerializableTypes && StyleProperty.NonSerializableStyleTypes.Contains(attribute.Type))
                {
                    continue;
                }

                //if (!restrictToSerializableTypes || StyleProperty.AlowedTypes.ContainsKey(attribute.GetType()))
                try
                {
                    list.Add(StyleProperty.FromAttribute(attribute));
                }
                catch (StylePropertyCreationException ex)
                {
                    // cannot be created
                }
            }

            return(list);
        }