private void Load()
{
this.UiTypes = new Dictionary<UIType, IUIFactory>();
Assembly[] assemblies = Game.EntityEventManager.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type[] types = assembly.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 (this.UiTypes.ContainsKey(attribute.Type))
{
throw new GameException($"已经存在同类UI Factory: {attribute.Type}");
}
IUIFactory iIuiFactory = Activator.CreateInstance(type) as IUIFactory;
if (iIuiFactory == null)
{
throw new GameException("UI Factory没有继承IUIFactory");
}
this.UiTypes.Add(attribute.Type, iIuiFactory);
}
}
}