Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleInjectorDependencyResolver"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="initializer">The initializer.</param>
        public SimpleInjectorDependencyResolver(Container container, SimpleInjectorInitializer initializer)
        {
            _container = container ?? throw new ArgumentNullException(nameof(container));
            _          = initializer ?? throw new ArgumentNullException(nameof(initializer));

            RegisterFactories(initializer);
        }
Exemplo n.º 2
0
 private void RegisterFactories(SimpleInjectorInitializer initializer)
 {
     foreach (KeyValuePair <Type, List <Func <object> > > typeFactories in initializer.RegisteredFactories)
     {
         _container.Collection.Register(
             typeFactories.Key,
             typeFactories.Value.Select(n =>
                                        new TransientSimpleInjectorRegistration(_container, typeFactories.Key, n)));
     }
 }
Exemplo n.º 3
0
 public static void UseSimpleInjectorDependencyResolver(this Container container, SimpleInjectorInitializer initializer) =>
 Locator.SetLocator(new SimpleInjectorDependencyResolver(container, initializer));