コード例 #1
0
ファイル: Injectable.cs プロジェクト: moialbla/ExtensionsCore
 /// <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();
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
ファイル: Injectable.cs プロジェクト: moialbla/ExtensionsCore
 /// <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;
 }