/// <summary>
 /// Add singleton
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementation"></param>
 /// <typeparam name="TService"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddSingletonService <TService>(this R bag, TService implementation)
 {
     bag.CheckNull(nameof(bag));
     bag.Register(DependencyProxyDescriptor.CreateForService <TService>(implementation, DependencyLifetimeType.Singleton));
     return(bag);
 }
 /// <summary>
 /// Add singleton
 /// </summary>
 /// <param name="bag"></param>
 /// <typeparam name="TImplementationSelf"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static R AddSingleton <TImplementationSelf>(this R bag)
 {
     bag.CheckNull(nameof(bag));
     bag.Register(DependencyProxyDescriptor.CreateForInstanceSelf <TImplementationSelf>(DependencyLifetimeType.Singleton));
     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);
 }
Esempio n. 4
0
 /// <summary>
 /// Try add Transient
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementation"></param>
 /// <typeparam name="TService"></typeparam>
 /// <exception cref="ArgumentNullException"></exception>
 public static void TryAddTransientService <TService>(this R bag, TService implementation)
 {
     bag.CheckNull(nameof(bag));
     bag.TryRegister(DependencyProxyDescriptor.CreateForService <TService>(implementation, DependencyLifetimeType.Transient));
 }
Esempio n. 5
0
 /// <summary>
 /// Try add Transient
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementationFunc"></param>
 /// <typeparam name="TService"></typeparam>
 /// <exception cref="ArgumentNullException"></exception>
 public static void TryAddTransientService <TService>(this R bag, Func <IDefinedResolver, object> implementationFunc)
 {
     bag.CheckNull(nameof(bag));
     implementationFunc.CheckNull(nameof(implementationFunc));
     bag.TryRegister(DependencyProxyDescriptor.CreateForResolvedServiceDelegate <TService>(implementationFunc, DependencyLifetimeType.Transient));
 }
Esempio n. 6
0
 /// <summary>
 /// Try add Transient
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementationFunc"></param>
 /// <param name="implementationType"></param>
 /// <exception cref="ArgumentNullException"></exception>
 public static void TryAddTransient(this R bag, Func <object> implementationFunc, Type implementationType)
 {
     bag.CheckNull(nameof(bag));
     implementationFunc.CheckNull(nameof(implementationFunc));
     bag.TryRegister(DependencyProxyDescriptor.CreateForObjectDelegate(implementationFunc, implementationType, DependencyLifetimeType.Transient));
 }
Esempio n. 7
0
 /// <summary>
 /// Try add Transient
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="serviceType"></param>
 /// <param name="implementationType"></param>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException"></exception>
 public static void TryAddTransient(this R bag, Type serviceType, Type implementationType)
 {
     bag.CheckNull(nameof(bag));
     bag.TryRegister(DependencyProxyDescriptor.CreateForType(serviceType, implementationType, DependencyLifetimeType.Transient));
 }
Esempio n. 8
0
 /// <summary>
 /// Try add Transient
 /// </summary>
 /// <param name="bag"></param>
 /// <typeparam name="TImplementationSelf"></typeparam>
 /// <exception cref="ArgumentNullException"></exception>
 public static void TryAddTransient <TImplementationSelf>(this R bag)
 {
     bag.CheckNull(nameof(bag));
     bag.TryRegister(DependencyProxyDescriptor.CreateForInstanceSelf <TImplementationSelf>(DependencyLifetimeType.Transient));
 }
Esempio n. 9
0
 /// <summary>
 /// Add Transient
 /// </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 AddTransient <TService, TImplementation>(this R bag, TImplementation implementation)
 {
     bag.CheckNull(nameof(bag));
     bag.Register(DependencyProxyDescriptor.CreateForService <TService, TImplementation>(implementation, DependencyLifetimeType.Transient));
     return(bag);
 }
Esempio n. 10
0
 /// <summary>
 /// Try add Transient
 /// </summary>
 /// <param name="bag"></param>
 /// <param name="implementationFunc"></param>
 /// <typeparam name="TImplementation"></typeparam>
 /// <exception cref="ArgumentNullException"></exception>
 public static void TryAddTransient <TImplementation>(this R bag, Func <TImplementation> implementationFunc)
 {
     bag.CheckNull(nameof(bag));
     implementationFunc.CheckNull(nameof(implementationFunc));
     bag.TryRegister(DependencyProxyDescriptor.CreateForInstanceDelegate(implementationFunc, DependencyLifetimeType.Transient));
 }