Exemplo n.º 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);
 }
Exemplo n.º 2
0
 public void AddModule(Type type, object obj) => injector.AddModule(type, obj);
Exemplo n.º 3
0
 public static void AddModule <T>(this IInjector injector, T obj) where T : notnull
 {
     injector.AddModule(typeof(T), obj);
 }
Exemplo n.º 4
0
 public void AddDynamicObject(object obj) => dynamicObjects.AddModule(obj);
Exemplo n.º 5
0
 public static void AddModule <T>(this IInjector injector, T obj)
 {
     injector.AddModule(typeof(T), obj);
 }