/// <summary>
 /// Add Scoped
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementationFunc"></param>
 /// <typeparam name="TService"></typeparam>
 /// <typeparam name="TImplementation"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddScoped <TService, TImplementation>(this R bag, Func <IDefinedResolver, TImplementation> implementationFunc)
 {
     bag.CheckNull(nameof(bag));
     implementationFunc.CheckNull(nameof(implementationFunc));
     bag.Register(DependencyProxyDescriptor.CreateForResolvedServiceDelegate <TService, TImplementation>(implementationFunc, DependencyLifetimeType.Scoped));
     return(bag);
 }
 /// <summary>
 /// Add Scoped
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementationFunc"></param>
 /// <typeparam name="TImplementation"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddScoped <TImplementation>(this R bag, Func <TImplementation> implementationFunc)
 {
     bag.CheckNull(nameof(bag));
     implementationFunc.CheckNull(nameof(implementationFunc));
     bag.Register(DependencyProxyDescriptor.CreateForInstanceDelegate(implementationFunc, DependencyLifetimeType.Scoped));
     return(bag);
 }
 /// <summary>
 /// Add Scoped
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementationFunc"></param>
 /// <param name="implementationType"></param>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddScoped(this R bag, Func <object> implementationFunc, Type implementationType)
 {
     bag.CheckNull(nameof(bag));
     implementationFunc.CheckNull(nameof(implementationFunc));
     bag.Register(DependencyProxyDescriptor.CreateForObjectDelegate(implementationFunc, implementationType, DependencyLifetimeType.Scoped));
     return(bag);
 }
 /// <summary>
 /// Add Singleton
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementationFunc"></param>
 /// <typeparam name="TService"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddSingletonService <TService>(this R bag, Func <IDefinedResolver, TService> implementationFunc)
 {
     bag.CheckNull(nameof(bag));
     implementationFunc.CheckNull(nameof(implementationFunc));
     bag.Register(DependencyProxyDescriptor.CreateForResolvedServiceDelegate <TService>(resolver => implementationFunc(resolver), DependencyLifetimeType.Singleton));
     return(bag);
 }
 /// <summary>
 /// Add singleton
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementationFunc"></param>
 /// <typeparam name="TService"></typeparam>
 /// <typeparam name="TImplementation"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddSingleton <TService, TImplementation>(this R bag, Func <TImplementation> implementationFunc)
 {
     bag.CheckNull(nameof(bag));
     implementationFunc.CheckNull(nameof(implementationFunc));
     bag.Register(DependencyProxyDescriptor.CreateForServiceDelegate <TService, TImplementation>(implementationFunc, DependencyLifetimeType.Singleton));
     return(bag);
 }
 /// <summary>
 /// Add Singleton
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementationFunc"></param>
 /// <param name="implementationType"></param>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddSingleton(this R bag, Func <IDefinedResolver, object> implementationFunc, Type implementationType)
 {
     bag.CheckNull(nameof(bag));
     implementationFunc.CheckNull(nameof(implementationFunc));
     bag.Register(DependencyProxyDescriptor.CreateForResolvedObjectDelegate(implementationFunc, implementationType, DependencyLifetimeType.Singleton));
     return(bag);
 }
 /// <summary>
 /// Add Singleton
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementationFunc"></param>
 /// <typeparam name="TImplementation"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddSingleton <TImplementation>(this R bag, Func <IDefinedResolver, TImplementation> implementationFunc)
 {
     bag.CheckNull(nameof(bag));
     implementationFunc.CheckNull(nameof(implementationFunc));
     bag.Register(DependencyProxyDescriptor.CreateForResolvedInstanceDelegate(implementationFunc, DependencyLifetimeType.Singleton));
     return(bag);
 }
Example #8
0
 /// <summary>
 /// Add Transient
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementationFunc"></param>
 /// <typeparam name="TService"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddTransient <TService>(this R bag, Func <object> implementationFunc)
 {
     bag.CheckNull(nameof(bag));
     implementationFunc.CheckNull(nameof(implementationFunc));
     bag.Register(DependencyProxyDescriptor.CreateForServiceDelegate <TService>(implementationFunc, DependencyLifetimeType.Transient));
     return(bag);
 }
 /// <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);
 }
 /// <summary>
 /// Add Scoped
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="serviceType"></param>
 /// <param name="implementationType"></param>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddScoped(this R bag, Type serviceType, Type implementationType)
 {
     bag.CheckNull(nameof(bag));
     bag.Register(DependencyProxyDescriptor.CreateForType(serviceType, implementationType, DependencyLifetimeType.Scoped));
     return(bag);
 }
 /// <summary>
 /// Add Scoped
 /// </summary>
 /// <param name="bag"></param>
 /// <typeparam name="TImplementationSelf"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddScoped <TImplementationSelf>(this R bag)
 {
     bag.CheckNull(nameof(bag));
     bag.Register(DependencyProxyDescriptor.CreateForInstanceSelf <TImplementationSelf>(DependencyLifetimeType.Scoped));
     return(bag);
 }
 /// <summary>
 /// Add singleton
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementation"></param>
 /// <param name="implementationType"></param>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddSingleton(this R bag, object implementation, Type implementationType)
 {
     bag.CheckNull(nameof(bag));
     bag.Register(DependencyProxyDescriptor.CreateForObject(implementation, implementationType, DependencyLifetimeType.Singleton));
     return(bag);
 }
Example #13
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);
 }