internal static void AddPropertyInjectableTypes(this IServiceCollection services, DependencyInjectionServiceType dependency) { switch (dependency.LifeTime) { case ServiceLifetime.Scoped: services.AddScoped(dependency.InterfaceType, provider => CreateInstance(provider, dependency.ImplementationType)); break; case ServiceLifetime.Singleton: services.AddSingleton(dependency.InterfaceType, provider => CreateInstance(provider, dependency.ImplementationType)); break; case ServiceLifetime.Transient: services.AddTransient(dependency.InterfaceType, provider => CreateInstance(provider, dependency.ImplementationType)); break; default: throw new NotImplementedException(); } }
internal static bool HasPropertyInjectAttribute(this DependencyInjectionServiceType dependency) { return(dependency.ImplementationType.GetProperties() .Any(p => p.GetCustomAttribute <InjectAttribute>() != null)); }