private static void InstanceSelfFuncRegister(IServiceCollection services, DependencyRegisterDescriptor d) { var lifetime = d.LifetimeType.ToMsLifetime(); switch (lifetime) { case ServiceLifetime.Scoped: services.AddScoped(p => d.InstanceFuncForImplementation()); break; case ServiceLifetime.Singleton: services.AddSingleton(p => d.InstanceFuncForImplementation()); break; case ServiceLifetime.Transient: services.AddTransient(p => d.InstanceFuncForImplementation()); break; default: services.AddTransient(p => d.InstanceFuncForImplementation()); break; } }
private static void InstanceSelfFuncRegister(IServiceContext services, DependencyRegisterDescriptor d) { var lifetime = d.LifetimeType.ToAspectCoreLifetime(); switch (lifetime) { case Lifetime.Scoped: services.AddDelegate(r => d.InstanceFuncForImplementation(), Lifetime.Scoped); break; case Lifetime.Singleton: services.AddDelegate(r => d.InstanceFuncForImplementation(), Lifetime.Singleton); break; case Lifetime.Transient: services.AddDelegate(r => d.InstanceFuncForImplementation()); break; default: services.AddDelegate(r => d.InstanceFuncForImplementation()); break; } }
private static void InstanceSelfFuncRegister(ContainerBuilder services, DependencyRegisterDescriptor d) { var builder = services.RegisterInstance(d.InstanceFuncForImplementation()); switch (d.LifetimeType) { case DependencyLifetimeType.Scoped: builder.InstancePerLifetimeScope(); break; case DependencyLifetimeType.Singleton: builder.SingleInstance(); break; case DependencyLifetimeType.Transient: builder.InstancePerDependency(); break; default: builder.InstancePerDependency(); break; } }
private static void TypeToInstanceFuncRegister(IServiceContext services, DependencyRegisterDescriptor d) { var lifetime = d.LifetimeType.ToAspectCoreLifetime(); services.AddDelegate(d.ServiceType, r => d.InstanceFuncForImplementation(), lifetime); }