コード例 #1
0
        /// <summary>
        /// Initializes all the appliers
        /// </summary>
        /// <returns></returns>
        private static List <IStyleApplyer> InitAppliers()
        {
            List <Type> allTypes = TypeReflector.GetAllLoadedTypes();
            var         appliers = new List <IStyleApplyer>();

            foreach (Type type in allTypes)
            {
                if (type.IsClass)
                {
                    if (typeof(IStyleApplyer).IsAssignableFrom(type))
                    {
                        //if (CoreReflector.HasClassAttributes<StyleAttribute>(type))
                        try
                        {
                            appliers.Add((IStyleApplyer)Activator.CreateInstance(type));
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("Cannot create style applier instance of " + type, ex);
                        }
                    }
                }
            }

            return(appliers);
        }
コード例 #2
0
        public static string Create()
        {
            var namespaces = new List <string>()
            {
                "System",
                "System.Collections.Generic",
                "UnityEngine"
            };

            StringBuilder sb       = new StringBuilder();
            var           allTypes = TypeReflector.GetAllLoadedTypes();

            //foreach (var type in allTypes)
            for (int i = 0; i < allTypes.Count; i++)
            {
                var type = allTypes[i];
                if (!namespaces.Contains(type.Namespace) && !string.IsNullOrEmpty(type.Namespace))
                {
                    namespaces.Add(type.Namespace);
                }

                if (i >= allTypes.Count - 1)
                {
                    sb.Append(string.Format("typeof({0})", type.Name));
                }
                else
                {
                    sb.AppendLine(string.Format("typeof({0}),", type.Name));
                }
            }

            StringBuilder ns = new StringBuilder();

            foreach (string s in namespaces)
            {
                ns.AppendLine(string.Format("using {0};", s));
            }

            return(string.Format(@"{0}
internal static class TypeReflector
{{
    internal static List<Type> GetList()
    {{
        var list = new List<Type>() {{
{1}
        }};
        return list;
    }}
}}", ns, sb));
        }
コード例 #3
0
        /// <summary>
        /// Gets all skin classes
        /// </summary>
        public static List <Type> GetAllStyleableClasses()
        {
            List <Type> allTypes = TypeReflector.GetAllLoadedTypes();
            List <Type> output   = new List <Type>();

            foreach (Type type in allTypes)
            {
                if (type.IsClass)
                {
                    if (/*!GuiComponentsOnly || */ StyleClientType.IsAssignableFrom(type))
                    {
                        if (CoreReflector.HasClassAttributes <StyleAttribute>(type))
                        {
                            output.Add(type);
                        }
                    }
                }
            }

            return(output);
        }