Exemplo n.º 1
0
        public static Cat Register(this Cat cat, Type from, Type to, Lifetime lifetime)
        {
            Func <Cat, Type[], object> factory = (_, arguments) => Create(_, to, arguments);

            cat.Register(new ServiceRegistry(from, lifetime, factory));
            return(cat);
        }
Exemplo n.º 2
0
        public static Cat Register <TServiceType>(this Cat cat, TServiceType instance)
        {
            Func <Cat, Type[], object> factory = (_, arguments) => instance;

            cat.Register(new ServiceRegistry(typeof(TServiceType), Lifetime.Root, factory));
            return(cat);
        }
Exemplo n.º 3
0
 public static Cat Register <TServiceType>(this Cat cat, Func <Cat, TServiceType> factory, Lifetime lifetime)
 {
     cat.Register(new ServiceRegistry(typeof(TServiceType), lifetime, (_, arguments) => factory(_)));
     return(cat);
 }
Exemplo n.º 4
0
 public static Cat Register <TFrom, TTo>(this Cat cat, Lifetime lifetime) where TTo : TFrom
 => cat.Register(typeof(TFrom), typeof(TTo), lifetime);