Example #1
0
 public void RegisterType <From, To>(bool isSingleton) where To : From
 {
     if (registerMap.ContainsKey(typeof(From)))
     {
         if (isSingleton)
         {
             registerMap[typeof(From)] = new SingletonObjectCreator(typeof(To));
         }
         else
         {
             registerMap[typeof(From)] = new CommonObjectCreator(typeof(To));
         }
     }
     else
     {
         if (isSingleton)
         {
             registerMap.Add(typeof(From), new SingletonObjectCreator(typeof(To)));
         }
         else
         {
             registerMap.Add(typeof(From), new CommonObjectCreator(typeof(To)));
         }
     }
 }
Example #2
0
 public void RegisterType <T>(bool isSingleton) where T : class
 {
     if (registerMap.ContainsKey(typeof(T)))
     {
         if (isSingleton)
         {
             registerMap[typeof(T)] = new SingletonObjectCreator(typeof(T));
         }
         else
         {
             registerMap[typeof(T)] = new CommonObjectCreator(typeof(T));
         }
     }
     else
     {
         if (isSingleton)
         {
             registerMap.Add(typeof(T), new SingletonObjectCreator(typeof(T)));
         }
         else
         {
             registerMap.Add(typeof(T), new CommonObjectCreator(typeof(T)));
         }
     }
 }