/// <summary> /// Controls when should new instances be created. See <see cref="Lifetime"/> for more detailed information. /// <param name="value"></param> /// </summary> public WeaklyTypedServiceConfigurator With(Lifetime value) { if (!EnumMetadata <Lifetime> .IsValidValue(value)) { throw new InvalidEnumValue <Lifetime>(value); } _lifetime = value; return(this); }
/// <summary> /// Controls if and when the instance should be disposed. <see cref="DisposeBehavior"/> for more detailed information. /// </summary> /// <param name="value"></param> /// <returns></returns> public WeaklyTypedServiceConfigurator With(DisposeBehavior value) { if (!EnumMetadata <DisposeBehavior> .IsValidValue(value)) { throw new InvalidEnumValue <DisposeBehavior>(value); } _disposeBehavior = value; return(this); }
/// <summary> /// Controls when should new instances be created. See <see cref="Lifetime"/> for more detailed information. /// <param name="value"></param> /// </summary> public StronglyTypedServiceConfigurator <TDependency, TInstance> With(Lifetime value) { if (!EnumMetadata <Lifetime> .IsValidValue(value)) { throw new InvalidEnumValue <Lifetime>(value); } _lifetime = value; return(this); }
/// <summary> /// Controls if and when the instance should be disposed. <see cref="DisposeBehavior"/> for more detailed information. /// </summary> /// <param name="value"></param> /// <returns></returns> public StronglyTypedServiceConfigurator <TDependency, TInstance> With(DisposeBehavior value) { if (!EnumMetadata <DisposeBehavior> .IsValidValue(value)) { throw new InvalidEnumValue <DisposeBehavior>(value); } _disposeBehavior = value; return(this); }
public ServiceBinding(SinglyLinkedListNode <Type> serviceTypes, BindingMetadata bindingMetadata, Expression expression, Lifetime lifetime = Lifetime.Transient, Action <object>?finalizer = null, DisposeBehavior needsDispose = DisposeBehavior.Default) { ServiceTypes = serviceTypes ?? throw new ArgumentNullException(nameof(serviceTypes)); BindingMetadata = bindingMetadata ?? throw new ArgumentNullException(nameof(bindingMetadata)); Lifetime = !EnumMetadata <Lifetime> .IsValidValue(lifetime) ? throw new InvalidEnumValueException <Lifetime>(lifetime) : lifetime; Expression = expression ?? throw new ArgumentNullException(nameof(expression)); NeedsDispose = !EnumMetadata <DisposeBehavior> .IsValidValue(needsDispose) ? throw new InvalidEnumValueException <DisposeBehavior>(needsDispose) : needsDispose; Finalizer = finalizer; }