Example #1
0
        public void Load()
        {
            UiTypes.Clear();

            List <Type> types = Game.EventSystem.GetTypes();

            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(UIFactoryAttribute), false);
                if (attrs.Length == 0)
                {
                    continue;
                }

                UIFactoryAttribute attribute = attrs[0] as UIFactoryAttribute;
                if (UiTypes.ContainsKey(attribute.Type))
                {
                    Log.Debug($"已经存在同类UI Factory: {attribute.Type}");
                    throw new Exception($"已经存在同类UI Factory: {attribute.Type}");
                }
                object           o       = Activator.CreateInstance(type);
                IUIFactoryExtend factory = o as IUIFactoryExtend;
                if (factory == null)
                {
                    Log.Error($"{o.GetType().FullName} 没有继承 IUIFactory");
                    continue;
                }
                this.UiTypes.Add(attribute.Type, factory);
            }
        }
Example #2
0
        public void Load()
        {
            UiTypes = new Dictionary <string, IUIFactory_Z>();

            foreach (Type type in ETModel.Game.Hotfix.GetHotfixTypes())
            {
                object[] attrs = type.GetCustomAttributes(typeof(UIFactoryAttribute), false);
                if (attrs.Length == 0)
                {
                    continue;
                }

                UIFactoryAttribute attribute = attrs[0] as UIFactoryAttribute;
                if (UiTypes.ContainsKey(attribute.Type))
                {
                    Log.Debug($"已经存在同类UI Factory: {attribute.Type}");
                    throw new Exception($"已经存在同类UI Factory: {attribute.Type}");
                }
                object       o       = Activator.CreateInstance(type);
                IUIFactory_Z factory = o as IUIFactory_Z;
                if (factory == null)
                {
                    Log.Error($"{o.GetType().FullName} 没有继承 IUIFactory");
                    continue;
                }
                this.UiTypes.Add(attribute.Type, factory);
            }
        }
Example #3
0
        public void Load()
        {
            uiMvcVessel.Clear();

            List <Type> types = Game.EventSystem.GetTypes();

            foreach (Type type in types)
            {
                object[] attrs = type.GetCustomAttributes(typeof(UIFactoryAttribute), true);
                if (attrs.Length == 0)
                {
                    attrs = type.GetCustomAttributes(typeof(UIComponentAttribute), true);
                    if (attrs.Length == 0)
                    {
                        continue;
                    }
                }

                Type attrType = attrs[0].GetType();
                if (typeof(UIFactoryAttribute) == attrType)
                {
                    UIFactoryAttribute factoryAttribute = attrs[0] as UIFactoryAttribute;
                    uiMvcVessel.AddUIMvcVessel(UIMvcVesselType.Factory, factoryAttribute.Type, type);
                }
                else if (typeof(UIComponentAttribute) == attrType)
                {
                    UIComponentAttribute componentAttribute = attrs[0] as UIComponentAttribute;
                    uiMvcVessel.AddUIMvcVessel(UIMvcVesselType.Componet, componentAttribute.Type, type);
                }
            }
        }