public void CollectionPropertyNoKeys()
        {
            ServiceLocatorConfiguration configuration = ServiceLocatorConfigurationTests.LoadConfiguration("DelayStrategiesNoKeys.config");

            CollectionPropertyConfigurationElement configElement = configuration.Services
                                                                   .OfType <ServiceConfigurationElement>()
                                                                   .Last()
                                                                   .ImplementationProperties
                                                                   .OfType <CollectionPropertyConfigurationElement>()
                                                                   .Single();

            Assert.IsNull(configElement.ResolveKeys);
        }
        public void CollectionPropertyEmptyKey()
        {
            ServiceLocatorConfiguration configuration = ServiceLocatorConfigurationTests.LoadConfiguration("DelayStrategiesEmptyKey.config");

            CollectionPropertyConfigurationElement configElement = configuration.Services
                                                                   .OfType <ServiceConfigurationElement>()
                                                                   .Last()
                                                                   .ImplementationProperties
                                                                   .OfType <CollectionPropertyConfigurationElement>()
                                                                   .Single();

            Assert.AreEqual(0, configElement.ResolveKeys.Count);
        }
        public void ConstructorValueParameter()
        {
            ServiceLocatorConfiguration configuration = ServiceLocatorConfigurationTests.LoadConfiguration("ConstantDelayStrategy.config");

            ConstructorValueConfigurationElement configElement = configuration.Services
                                                                 .OfType <ServiceConfigurationElement>()
                                                                 .Single()
                                                                 .ImplementationConstructorParameters
                                                                 .OfType <ConstructorValueConfigurationElement>()
                                                                 .Single();

            Assert.AreEqual("00:15:00", configElement.ValueAsString);

            Assert.AreEqual(TimeSpan.FromMinutes(15), configElement.ConvertedValue);
        }
        public void PropertyValue()
        {
            ServiceLocatorConfiguration configuration = ServiceLocatorConfigurationTests.LoadConfiguration("TimerWithInterval.config");

            ValuePropertyConfigurationElement configElement = configuration.Services
                                                              .OfType <ServiceConfigurationElement>()
                                                              .Single()
                                                              .ImplementationProperties
                                                              .OfType <ValuePropertyConfigurationElement>()
                                                              .Single();

            Assert.AreEqual("00:15:00", configElement.ValueAsString);

            Assert.AreEqual(TimeSpan.FromMinutes(15), configElement.ConvertedValue);
        }
        public void ConstructorResolveParameterByKey()
        {
            ServiceLocatorConfiguration configuration = ServiceLocatorConfigurationTests.LoadConfiguration("DateTimeProviderWithValidTimerKey.config");

            ServiceConfigurationElement serviceConfig = configuration.Services
                                                        .OfType <ServiceConfigurationElement>()
                                                        .Last();

            Assert.IsNotNull(serviceConfig.ImplementationConstructorParameters.ResolvedConstructorInfo);

            ConstructorResolveConfigurationElement configElement = serviceConfig.ImplementationConstructorParameters
                                                                   .OfType <ConstructorResolveConfigurationElement>()
                                                                   .Single();

            Assert.AreEqual("MyTimer", configElement.ResolveKey);
        }
        public void CollectionPropertyTwoKeys()
        {
            ServiceLocatorConfiguration configuration = ServiceLocatorConfigurationTests.LoadConfiguration("DelayStrategiesTwoKeys.config");

            CollectionPropertyConfigurationElement configElement = configuration.Services
                                                                   .OfType <ServiceConfigurationElement>()
                                                                   .Last()
                                                                   .ImplementationProperties
                                                                   .OfType <CollectionPropertyConfigurationElement>()
                                                                   .Single();

            Assert.AreEqual(2, configElement.ResolveKeys.Count);

            Assert.AreEqual("None", configElement.ResolveKeys[0]);
            Assert.AreEqual("Exponential", configElement.ResolveKeys[1]);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RadoslavServiceLocator"/> class.
        /// </summary>
        /// <param name="configuration">Service locator configuration.</param>
        /// <exception cref="ArgumentNullException">Parameter <see cref="configuration"/> is null.</exception>
        private RadoslavServiceLocator(ServiceLocatorConfiguration configuration)
        {
            Trace.WriteLine("ENTER: Constructing {0} ...".FormatInvariant(this.GetType().Name));

            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            this.configuration = configuration;

            if (this.configuration.Services.HasSelfRegistration)
            {
                this.singletonInstancesByImplementationType.Add(typeof(RadoslavServiceLocator), this);
            }

            Trace.WriteLine("EXIT: {0} constructed.".FormatInvariant(this.GetType().Name));
        }
 /// <summary>
 /// Loads from configuration.
 /// </summary>
 /// <param name="service">The service.</param>
 /// <param name="configuration">The configuration.</param>
 /// <returns></returns>
 public static Lazy <IServiceLocator> LoadFromConfiguration(this Lazy <IServiceLocator> service, ServiceLocatorConfiguration configuration)
 {
     ServiceLocatorManager.GetSetupDescriptor(service).LoadFromConfiguration(service, configuration); return(service);
 }
 /// <summary>
 /// Loads from configuration.
 /// </summary>
 /// <param name="descriptor">The descriptor.</param>
 /// <param name="service">The service.</param>
 /// <param name="configuration">The configuration.</param>
 public static void LoadFromConfiguration(this ServiceLocatorManager.ISetupDescriptor descriptor, Lazy <IServiceLocator> service, ServiceLocatorConfiguration configuration)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
 }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AttributeIndex"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 public AttributeIndex(ServiceLocatorConfiguration parent)
 {
     _parent = parent;
 }