/// <summary> /// Try add Scoped /// </summary> /// <param name="bag"></param> /// <param name="implementation"></param> /// <param name="implementationType"></param> /// <exception cref="ArgumentNullException"></exception> public static void TryAddScoped(this R bag, object implementation, Type implementationType) { bag.CheckNull(nameof(bag)); bag.TryRegister(DependencyProxyDescriptor.CreateForObject(implementation, implementationType, DependencyLifetimeType.Scoped)); }
/// <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); }