Ejemplo n.º 1
0
 /// <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);
 }
Ejemplo n.º 2
0
 /// <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);
 }
Ejemplo n.º 3
0
 /// <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);
 }
Ejemplo n.º 4
0
 /// <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);
 }
Ejemplo n.º 5
0
        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;
        }