internal static void AutoCreateEntities(BaseInjectionBinder binder) { var typeDic = InjectionUtils.GetTypesWithAttribute <AutoCreateAttribute>(); List <object> cloudsCreated = new List <object>(); List <object> signalsCreated = new List <object>(); foreach (var typeKVP in typeDic) { var type = typeKVP.Key; var attribute = typeKVP.Value; var binderType = attribute.BinderType; if (binderType != null && binder.GetType().IsAssignableFrom(binderType) == false) { continue; //This entity does not permit auto creation from this binder } if (BASE_SIGNAL_TYPE.IsAssignableFrom(type)) { bool isNew; var newSignal = GetOrMakeSignal(type, out isNew, "[AutoCreate]-" + type.ToString()); if (isNew) { signalsCreated.Add(newSignal); } } else if (InjectionUtils.GetAttribute <CloudAttribute>(type) != null) { if (_cloudDictionary.ContainsKey(type)) { continue; /* * Cloud already exists, * this may be normal behaviour if two Scenes * have invoked the AutoCreate via their binders */ } cloudsCreated.Add(CreateCloud(type)); } else { Debug.LogWarning("Can't AutoCreate type " + type.ToString() + " Ignoring"); } } foreach (var cloudCreated in cloudsCreated) { Binder._onStart.AddOnce(() => InjectBehaviourInner(cloudCreated)); Binder._onStartFinished.AddOnce(() => CallStartMethod(cloudCreated)); } foreach (var signalCreate in signalsCreated) { Binder._onStart.AddOnce(() => InjectSignal(signalCreate)); Binder._onStartFinished.AddOnce(() => CallSignalStart(signalCreate)); } }
public void ActivateClient(List <Activator> coreActivators, List <Activator> nonCoreActivators) { this.coreActivators = coreActivators; this.nonCoreActivators = nonCoreActivators; InjectionUtils.RegisterInjectionPoints(typeof(InjectAttribute), ServiceRegistry.Current); this.LaunchCoreActivators(); }
public static void Clean() { AssetBundleDiskCache.Clean(); AssetBundlesStorage.Clean(); ServiceRegistry.Reset(); InjectionUtils.ClearInjectionPoints(typeof(InjectAttribute)); BaseElementCanvasScaler.MarkNeedInitialize(); FatalErrorHandler.IsErrorScreenWasShown = false; }
private static bool CanInjectCloud(PropertyInfo prop, Inject inject, object obj) { bool isValidInjectType = (inject.Type == InjectType.Cloud || inject.Type == InjectType.Auto); if (isValidInjectType == false) { return(false); } var cloudAttribute = InjectionUtils.GetAttribute <CloudAttribute>(prop.PropertyType); bool hasCloudAttribute = cloudAttribute != null; return(hasCloudAttribute); }
internal static void InjectBehaviourInner(object obj) { List <System.Type> typeChain = InjectionUtils.GetObjectTypeChain(obj); foreach (var t in typeChain) { var properties = t.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); foreach (var prop in properties) { var injectAttribute = InjectionUtils.GetAttribute <Inject>(prop); if (injectAttribute != null) { InjectPropertyIntoObjByAttribute(obj, prop, injectAttribute); } } } }
internal static void CallStartMethod(object cloud) { InjectionUtils.CallAttributedMethod(cloud, START_ATTR_TYPE, INSTANCE_METHOD_FLAGS); }
internal static void CallSignalStart(object signal) { InjectionUtils.CallAttributedMethod(signal, START_ATTR_TYPE, INSTANCE_METHOD_FLAGS); }