Beispiel #1
0
 public Implementation(Type type, DependencyTTL dependencyTTL = DependencyTTL.IPD, DependencyProvider provider = null)
 {
     this.type          = type;
     this.dependencyTTL = dependencyTTL;
     if (dependencyTTL == DependencyTTL.SINGLETON)
     {
         if (provider == null)
         {
             //throw error
         }
         else
         {
             this.instance = provider.Resolve(type);
         }
     }
 }
Beispiel #2
0
 public void Register(Type tDependency, Type tImplementation, DependencyTTL dependencyTTL = DependencyTTL.IPD)
 {
     if (RegistrationIsValid(tDependency, tImplementation))
     {
         if (!Implementations.TryGetValue(tDependency, out IList <Implementation> implementations))
         {
             implementations = new List <Implementation>();
         }
         if (implementations.Where(impl => impl.type == tImplementation && impl.dependencyTTL == dependencyTTL).Count() == 0)
         {
             implementations.Add(new Implementation(tImplementation, dependencyTTL));
             Implementations[tDependency] = implementations;
         }
     }
     else
     {
         throw new Exception("Is not valid");
     }
 }
Beispiel #3
0
 public void Register <TDependency, TImplementation>(DependencyTTL dependencyTTL = DependencyTTL.IPD)
 {
     this.Register(typeof(TDependency), typeof(TImplementation), dependencyTTL);
 }