/// <summary>
 /// Try add Scoped
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementation"></param>
 /// <typeparam name="TService"></typeparam>
 /// <exception cref="ArgumentNullException"></exception>
 public static void TryAddScopedService <TService>(this R bag, TService implementation)
 {
     bag.CheckNull(nameof(bag));
     bag.TryRegister(DependencyProxyDescriptor.CreateForService <TService>(implementation, DependencyLifetimeType.Scoped));
 }
 /// <summary>
 /// Add Scoped
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementation"></param>
 /// <typeparam name="TService"></typeparam>
 /// <typeparam name="TImplementation"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddScoped <TService, TImplementation>(this R bag, TImplementation implementation)
 {
     bag.CheckNull(nameof(bag));
     bag.Register(DependencyProxyDescriptor.CreateForService <TService, TImplementation>(implementation, DependencyLifetimeType.Scoped));
     return(bag);
 }
示例#3
0
 /// <summary>
 /// Try add Transient
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementation"></param>
 /// <typeparam name="TService"></typeparam>
 /// <typeparam name="TImplementation"></typeparam>
 /// <exception cref="ArgumentNullException"></exception>
 public static void TryAddTransient <TService, TImplementation>(this R bag, TImplementation implementation)
 {
     bag.CheckNull(nameof(bag));
     bag.TryRegister(DependencyProxyDescriptor.CreateForService <TService, TImplementation>(implementation, DependencyLifetimeType.Transient));
 }
 /// <summary>
 /// Try add Singleton
 /// </summary>
 /// <param name="bag"></param>
 /// <typeparam name="TService"></typeparam>
 /// <typeparam name="TImplementation"></typeparam>
 /// <exception cref="ArgumentNullException"></exception>
 public static void TryAddSingleton <TService, TImplementation>(this R bag)
 {
     bag.CheckNull(nameof(bag));
     bag.TryRegister(DependencyProxyDescriptor.CreateForService <TService, TImplementation>(DependencyLifetimeType.Singleton));
 }
示例#5
0
 /// <summary>
 /// Add Transient
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementation"></param>
 /// <typeparam name="TService"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddTransientService <TService>(this R bag, TService implementation)
 {
     bag.CheckNull(nameof(bag));
     bag.Register(DependencyProxyDescriptor.CreateForService <TService>(implementation, DependencyLifetimeType.Transient));
     return(bag);
 }