Пример #1
0
 /// <summary>
 ///     Add Default Mode for a ServiceLifeTime
 /// </summary>
 /// <param name="configuarations"></param>
 /// <param name="services"></param>
 /// <param name="lifetime"></param>
 /// <returns>a instance of IInyectorConfiguration</returns>
 public static InyectorConfiguration DefaultMode(this InyectorConfiguration configuarations,
                                                 IServiceCollection services,
                                                 ServiceLifetime lifetime)
 {
     configuarations.DefaultMode(AspNetCoreModeFactory.Create(lifetime, services).InyectorMethod);
     return(configuarations);
 }
Пример #2
0
        public static IServiceCollection UseInjector(this IServiceCollection services,
                                                     Action <InyectorConfiguration> configurationAction)
        {
            // Call Inyector Startup
            InyectorStartup.Init((c) =>
            {
                // add default modes
                c.AddMode(AspNetCoreModeFactory.Create(ServiceLifetime.Scoped, services))
                .AddMode(AspNetCoreModeFactory.Create(ServiceLifetime.Singleton, services))
                .AddMode(AspNetCoreModeFactory.Create(ServiceLifetime.Transient, services));

                configurationAction.Invoke(c);
            });

            return(services);
        }