/// <summary> /// Basic constructor. /// </summary> /// <param name="instanceOf">Interface</param> /// <param name="injectionType">Injection type. By default singlenton</param> public InjectableAttribute(Type instanceOf, DependencyInjectionTypes injectionType = DependencyInjectionTypes.Singlenton) { if (instanceOf is null) { throw new ArgumentNullException(nameof(instanceOf)); } InstaceOf = instanceOf; DependencyType = injectionType; //Internal GUID Name = Guid.NewGuid().ToString(); }
private static void AddInjection(IServiceCollection services, DependencyInjectionTypes type, Type zinterface, Type zclass) { if (type == DependencyInjectionTypes.Singlenton) { services.AddSingleton(zinterface, zclass); } else if (type == DependencyInjectionTypes.Scoped) { services.AddScoped(zinterface, zclass); } else if (type == DependencyInjectionTypes.Transient) { services.AddTransient(zinterface, zclass); } }
/// <summary> /// Advance constructor. /// </summary> /// <param name="instanceOf">Interface</param> /// <param name="injectionType">Injection type. By default singlenton.</param> /// <param name="name">The reference name.</param> public InjectableAttribute(Type instanceOf, DependencyInjectionTypes injectionType, String name) : this(instanceOf, injectionType) { this.Name = name; }