public BeanAttribute(InstantiateMod instantiateMod) { InstantiateMod = instantiateMod; if (instantiateMod == InstantiateMod.Singleton) { SingletonLoadMod = SingletonLoadMod.InTime; } }
public void RegisterSingleton <T>(SingletonLoadMod loadMod = SingletonLoadMod.InTime) where T : class { var genericType = typeof(T); var memberName = genericType.Name; if (IsSingletonRegistered(memberName)) { return; } if (loadMod == SingletonLoadMod.InTime) { _singletonObjectDic.Add(memberName, CreateInstance(genericType)); } else { _unloadedSingletonDic.Add(memberName, genericType); } }
public void RegisterSingleton <TInterface, TInstance>(SingletonLoadMod loadMod = SingletonLoadMod.InTime) where TInstance : TInterface { var interfaceName = typeof(TInterface).Name; if (_singletonObjectDic.ContainsKey(interfaceName)) { return; } var instanceType = typeof(TInstance); if (loadMod == SingletonLoadMod.InTime) { _singletonObjectDic.Add(interfaceName, Activator.CreateInstance(instanceType)); } else { _unloadedSingletonDic.Add(interfaceName, instanceType); } }
public BeanAttribute(SingletonLoadMod singletonLoadMod) { InstantiateMod = InstantiateMod.Singleton; SingletonLoadMod = singletonLoadMod; }
public BeanAttribute() { InstantiateMod = InstantiateMod.Singleton; SingletonLoadMod = SingletonLoadMod.InTime; }