Пример #1
0
 public BeanAttribute(InstantiateMod instantiateMod)
 {
     InstantiateMod = instantiateMod;
     if (instantiateMod == InstantiateMod.Singleton)
     {
         SingletonLoadMod = SingletonLoadMod.InTime;
     }
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
 public BeanAttribute(SingletonLoadMod singletonLoadMod)
 {
     InstantiateMod   = InstantiateMod.Singleton;
     SingletonLoadMod = singletonLoadMod;
 }
Пример #5
0
 public BeanAttribute()
 {
     InstantiateMod   = InstantiateMod.Singleton;
     SingletonLoadMod = SingletonLoadMod.InTime;
 }