Beispiel #1
0
        public T Get <T>() where T : class
        {
            if (!IsInitilized)
            {
                Init();
            }

            Type instanceType = typeof(T);

            if (Singletons.ContainsKey(instanceType))
            {
                return((T)Singletons[instanceType]);
            }

            if (Factories.ContainsKey(instanceType))
            {
                return((T)Factories[instanceType].Invoke());
            }

            if (AsyncFactories.ContainsKey(instanceType))
            {
                return((T)AsyncFactories[instanceType].Invoke().Result);
            }
            return(null);
        }
Beispiel #2
0
 public T Single <T>()
 {
     if (Singletons.ContainsKey(typeof(T)))
     {
         return((T)Singletons[typeof(T)]);
     }
     return(default(T));
 }