Exemplo n.º 1
0
 // 自己提供工厂
 public static Cat Register(this Cat cat, Type serviceType, Func <Cat, object> factory, LifeTime lifeTime)
 {
     cat.Register(new ServiceRegistry(serviceType, lifeTime, (container, args) => factory(container)));
     return(cat);
 }
Exemplo n.º 2
0
 public static Cat Register <TService>(this Cat cat, Func <Cat, object> factory, LifeTime lifeTime)
 {
     cat.Register(new ServiceRegistry(typeof(TService), lifeTime, (container, args) => factory(container)));
     return(cat);
 }
Exemplo n.º 3
0
 public static Cat Register <TFrom, TTo>(this Cat cat, LifeTime lifeTime) where TTo : TFrom
 {
     return(cat.Register(typeof(TFrom), typeof(TTo), lifeTime));
 }