/// <summary>
 /// Construct attribute with service type, reuse, multiple constructor flag and a priority
 /// </summary>
 /// <param name="serviceType">The type that the service should be registered as</param>
 /// <param name="reuse">Indicate reuse policy for the service</param>
 /// <param name="multipleConstructors">Indicate if the service has multiple constructors</param>
 /// <param name="priority">Priority of the class in case of multiple implementers. Higher values takes priority</param>
 public AutomaticContainerRegistrationAttribute(Type serviceType, ServiceReuse reuse, bool multipleConstructors,
                                                int priority)
     : base(reuse, multipleConstructors)
 {
     ServiceType = serviceType;
     Priority    = priority;
 }
        public void ConvertSingletonVaraniumReuseToDryIocReuse()
        {
            // arrange
            const ServiceReuse varaniumReuse = ServiceReuse.Singleton;
            var dryIocReuse = Reuse.Singleton;

            // act
            var result = varaniumReuse.ConvertFromVaraniumReuse();

            // assert
            result.Should().Be(dryIocReuse);
        }
        public void ConvertDefaultVaraniumReuseToDryIocReuse()
        {
            // arrange
            const ServiceReuse varaniumReuse = ServiceReuse.Default;
            var dryIocReuse = Reuse.Transient;

            // act
            var result = varaniumReuse.ConvertFromVaraniumReuse();

            // assert
            result.Should().Be(dryIocReuse);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Convert a VaraniumSharp ServiceReuse enum value into a IReuse value used by DryIoc
        /// </summary>
        /// <param name="self"></param>
        /// <returns></returns>
        public static IReuse ConvertFromVaraniumReuse(this ServiceReuse self)
        {
            IReuse result;

            switch (self)
            {
            case ServiceReuse.Singleton:
                result = Reuse.Singleton;
                break;

            default:
                result = Reuse.Transient;
                break;
            }
            return(result);
        }
 /// <summary>
 /// Construct attribute with service type, reuse and multiple constructor flag
 /// </summary>
 /// <param name="serviceType">The type that the service should be registered as</param>
 /// <param name="reuse">Indicate reuse policy for the service</param>
 /// <param name="multipleConstructors">Indicate if the service has multiple constructors</param>
 public AutomaticContainerRegistrationAttribute(Type serviceType, ServiceReuse reuse,
                                                bool multipleConstructors)
     : this(serviceType, reuse, multipleConstructors, 0)
 {
 }
 /// <summary>
 /// Construct attribute with service type and reuse
 /// </summary>
 /// <param name="serviceType">The type that the service should be registered as</param>
 /// <param name="reuse">Indicate reuse policy for the service</param>
 public AutomaticContainerRegistrationAttribute(Type serviceType, ServiceReuse reuse)
     : this(serviceType, reuse, false)
 {
 }
 /// <summary>
 /// Constructor that allows setting Reuse directly
 /// </summary>
 /// <param name="reuse">Indicate service reuse type</param>
 /// <param name="multipleConstructors">Indicate if the service has multiple constructors</param>
 public AutomaticConcretionContainerRegistrationAttribute(ServiceReuse reuse, bool multipleConstructors)
     : base(reuse, multipleConstructors)
 {
 }
 /// <summary>
 /// Constructor that allows setting Reuse directly
 /// </summary>
 /// <param name="reuse">Indicate service reuse type</param>
 public AutomaticConcretionContainerRegistrationAttribute(ServiceReuse reuse)
     : this(reuse, false)
 {
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Construcor that allows setting Reuse
 /// </summary>
 /// <param name="reuse">Indicate reuse policy for the service</param>
 /// <param name="multipleConstructors">Indicate if the service has multiple constructors</param>
 protected AutomaticContainerRegistrationBaseAttribute(ServiceReuse reuse, bool multipleConstructors)
 {
     Reuse = reuse;
     MultipleConstructors = multipleConstructors;
 }