Exemplo n.º 1
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="serviceType"></param>
 /// <param name="lifetime"></param>
 /// <param name="factory"></param>
 public ServiceRegistry(
     Type serviceType,
     LifecCycle lifetime,
     Func <ObjectDI, Type[], object> factory)
 {
     ServiceType = serviceType;
     LifecCycle  = lifetime;
     Factory     = factory;
 }
Exemplo n.º 2
0
 public static ObjectDI Register <TServiceType>(
     this ObjectDI cat,
     Func <ObjectDI, TServiceType> factory,
     LifecCycle lifetime)
 {
     cat.Register(new ServiceRegistry(
                      typeof(TServiceType), lifetime, (_, arguments) => factory(_)));
     return(cat);
 }
Exemplo n.º 3
0
        public static ObjectDI Register(
            this ObjectDI cat,
            Type from,
            Type to,
            LifecCycle lifetime)
        {
            Func <ObjectDI, Type[], object> factory =
                (_, arguments) => Create(_, to, arguments);

            cat.Register(new ServiceRegistry(from, lifetime, factory));
            return(cat);
        }
Exemplo n.º 4
0
 public static ObjectDI Register <TFrom, TTo>(
     this ObjectDI cat,
     LifecCycle lifetime) where TTo : TFrom
 => cat.Register(typeof(TFrom), typeof(TTo), lifetime);