예제 #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;
 }
예제 #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);
 }
예제 #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);
        }
예제 #4
0
 public static ObjectDI Register <TFrom, TTo>(
     this ObjectDI cat,
     LifecCycle lifetime) where TTo : TFrom
 => cat.Register(typeof(TFrom), typeof(TTo), lifetime);