예제 #1
0
 /// <summary>Creates all modules.</summary>
 /// <returns>True if all are initialized, false otherwise.</returns>
 public bool Build()
 {
     for (var curNode = modules.Last; curNode != null; curNode = curNode.Previous, modules.RemoveLast())
     {
         var cur = curNode.Value;
         var obj = injector.GetModule(cur.TImplementation);
         if (obj != null)
         {
             injector.AddModule(cur.TService, obj);
         }
         else
         {
             if (!injector.TryCreate(cur.TImplementation, out obj))
             {
                 return(false);
             }
             injector.AddModule(cur.TService, obj);
         }
     }
     return(true);
 }
예제 #2
0
 public void AddModule(Type type, object obj) => injector.AddModule(type, obj);
예제 #3
0
 public static void AddModule <T>(this IInjector injector, T obj) where T : notnull
 {
     injector.AddModule(typeof(T), obj);
 }
예제 #4
0
 public void AddDynamicObject(object obj) => dynamicObjects.AddModule(obj);
예제 #5
0
 public static void AddModule <T>(this IInjector injector, T obj)
 {
     injector.AddModule(typeof(T), obj);
 }