예제 #1
0
        public void Register <T>(Func <IDependencyResolver, T> builder, Lifetime lifetime = Lifetime.AlwaysNew) where T : class
        {
            Type          type = typeof(T);
            Func <object> next = () => WrapLifecycle(builder, lifetime)(this);

            if (_registrations.ContainsKey(type))
            {
                Func <object> previous = _registrations[type];
                _registrations[type] = next;
                RegisterManyUnnamed(type, previous);
            }
            else
            {
                _registrations[type] = next;
            }
        }
예제 #2
0
        public IDependencyRegistrar Register <T>(Func <IDependencyResolver, T> builder,
                                                 Lifetime lifetime = Lifetime.AlwaysNew)
            where T : class
        {
            var type = typeof(T);

            if (_registrations.ContainsKey(type))
            {
                var previous = _registrations[type];
                _registrations[type] = () => WrapLifecycle(builder, lifetime)(this);
                RegisterManyUnnamed(type, previous);
            }
            else
            {
                _registrations[type] = () => WrapLifecycle(builder, lifetime)(this);
            }

            return(this);
        }