Beispiel #1
0
        public static void RegisterPerScope(this IContainer container, Type fromType, Type toType, string key = null)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            var lifetimeManager = new PerScopeLifetimeManager(toType, container);

            container.Register(lifetimeManager, fromType, key);
        }
Beispiel #2
0
        public static void RegisterPerScope(this IContainer container, Type type, string key = null, Func <IResolver, object> factory = null)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            if (factory == null)
            {
                container.RegisterPerScope(type, type, key);
                return;
            }

            var lifetimeManager = new PerScopeLifetimeManager(type, container, factory);

            container.Register(lifetimeManager, type, key);
        }