Ejemplo n.º 1
0
 public BeanAttribute(InstantiateMod instantiateMod)
 {
     InstantiateMod = instantiateMod;
     if (instantiateMod == InstantiateMod.Singleton)
     {
         SingletonLoadMod = SingletonLoadMod.InTime;
     }
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 4
0
 public BeanAttribute(SingletonLoadMod singletonLoadMod)
 {
     InstantiateMod   = InstantiateMod.Singleton;
     SingletonLoadMod = singletonLoadMod;
 }
Ejemplo n.º 5
0
 public BeanAttribute()
 {
     InstantiateMod   = InstantiateMod.Singleton;
     SingletonLoadMod = SingletonLoadMod.InTime;
 }