Example #1
0
        private static void RegisterScreensFromAssembly(Assembly assembly)
        {
            if (assembly == null)
            {
                return;
            }

            var baseScreen = typeof(MyGuiScreenBase);

            foreach (var type in assembly.GetTypes())
            {
                if (!baseScreen.IsAssignableFrom(type))
                {
                    continue;
                }

                var attributes = type.GetCustomAttributes(typeof(MyDebugScreenAttribute), false);
                if (attributes.Length == 0)
                {
                    continue;
                }

                var attribute = (MyDebugScreenAttribute)attributes[0];
                SortedDictionary <string, MyDevelopGroupTypes> typesInGroup;
                if (!s_developScreenTypes.TryGetValue(attribute.Group, out typesInGroup))
                {
                    typesInGroup = new SortedDictionary <string, MyDevelopGroupTypes>();
                    s_developScreenTypes.Add(attribute.Group, typesInGroup);
                    s_developGroups.Add(attribute.Group, new MyDevelopGroup(attribute.Group));
                }
                MyDevelopGroupTypes val = new MyDevelopGroupTypes(type, attribute.DirectXSupport);
                typesInGroup.Add(attribute.Name, val);
            }
        }
Example #2
0
        private static void RegisterScreensFromAssembly(Assembly assembly)
        {
            if (assembly == null)
            {
                return;
            }

            var baseScreen = typeof(MyGuiScreenBase);

#if XB1 // XB1_ALLINONEASSEMBLY
            System.Diagnostics.Debug.Assert(m_registered == false);
            if (m_registered == true)
            {
                return;
            }
            m_registered = true;
            foreach (var type in MyAssembly.GetTypes())
#else // !XB1
            foreach (var type in assembly.GetTypes())
#endif // !XB1
            {
                if (!baseScreen.IsAssignableFrom(type))
                {
                    continue;
                }

                var attributes = type.GetCustomAttributes(typeof(MyDebugScreenAttribute), false);
                if (attributes.Length == 0)
                {
                    continue;
                }

                var attribute = (MyDebugScreenAttribute)attributes[0];
                SortedDictionary <string, MyDevelopGroupTypes> typesInGroup;
                if (!s_developScreenTypes.TryGetValue(attribute.Group, out typesInGroup))
                {
                    typesInGroup = new SortedDictionary <string, MyDevelopGroupTypes>();
                    s_developScreenTypes.Add(attribute.Group, typesInGroup);
                    s_developGroups.Add(attribute.Group, new MyDevelopGroup(attribute.Group));
                }
                MyDevelopGroupTypes val = new MyDevelopGroupTypes(type, attribute.DirectXSupport);
                typesInGroup.Add(attribute.Name, val);
            }
        }