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