コード例 #1
0
        protected void Context()
        {
            currentEventSequence          = 0;
            provider1ReconfiguredSequence = -1;
            provider2ReconfiguredSequence = -1;
            sourceChangedEventArgs        = null;

            configurator = new MockChangeTrackingConfigurator();
            configSource = new MockConfigSource();

            var mockProvider1 = new Mock <ITypeRegistrationsProvider>();

            mockProvider1.Setup(p => p.GetRegistrations(It.IsAny <IConfigurationSource>()))
            .Returns(MakeRegistration <DummyClass1>());

            var mockProvider2 = new Mock <ITypeRegistrationsProvider>();

            mockProvider2.Setup(p => p.GetRegistrations(It.IsAny <IConfigurationSource>()))
            .Returns(MakeRegistration <DummyClass2>());

            var mockComposite = new Mock <ITypeRegistrationsProvider>();

            mockComposite.Setup(c => c.GetRegistrations(It.IsAny <IConfigurationSource>()))
            .Returns(
                (IConfigurationSource cs) => mockProvider1.Object.GetRegistrations(cs)
                .Concat(mockProvider2.Object.GetRegistrations(cs)));


            configurator.EventSource.SourceChanged += Configurator_OnConfigurationSourceChanged;
            configurator.ContainerReconfiguring    += MockProvider1_OnContainerReconfiguring;
            configurator.ContainerReconfiguring    += MockProvider2_OnContainerReconfiguring;

            configurator.RegisterAll(configSource, mockComposite.Object);
        }
コード例 #2
0
        /// <summary>
        /// Utility function to raise the <see cref="SourceChanged"/> event.
        /// </summary>
        /// <param name="configurationSource">Configuration source that changed.</param>
        /// <param name="container"><see cref="IServiceLocator"/> object that has been configured with the
        /// contents of <paramref name="configurationSource"/>.</param>
        /// <param name="changedSectionNames">Sequence of the section names in <paramref name="configurationSource"/>
        /// that have changed.</param>
        protected virtual void OnSourceChanged(IConfigurationSource configurationSource,
                                               IServiceLocator container,
                                               IEnumerable <string> changedSectionNames)
        {
            EventHandler <ConfigurationSourceChangedEventArgs> handler = SourceChanged;

            if (handler != null)
            {
                var eventArgs = new ConfigurationSourceChangedEventArgs(configurationSource, container, changedSectionNames);
                handler(this, eventArgs);
            }
        }
        protected override void Act()
        {
            base.ConfigurationSourceHandler.DoEnsurePropagatingSectionChangeEvents(SubordinateSource1Name, "Section1");
            base.ConfigurationSourceHandler.DoEnsurePropagatingSectionChangeEvents(SubordinateSource1Name, "Section2");

            ConfigurationSourceHandler.ConfigurationSourceChanged += (sender, args) =>
            {
                sourceChangedEvent = args;
            };

            base.ConfigurationSourceHandler.DoPublicRefresh();
        }
コード例 #4
0
        public void Given()
        {
            eventSource         = new ConfigurationChangeEventSourceImpl();
            configurationSource = new DictionaryConfigurationSource();
            configurationSource.Add(testsSectionName, new TestsConfigurationSection());
            mockLocator = new Mock <IServiceLocator>().Object;

            eventSource.SourceChanged += (sender, e) => { sourceChangedEventArgs = e; };

            eventSource.GetSection <TestsConfigurationSection>().SectionChanged +=
                (sender, e) => { sectionChangedEventArgs = e; };

            eventSource.GetSection <AppSettingsSection>().SectionChanged +=
                (sender, e) => { appSettingsChangedEventArgs = e; };

            eventSource.ConfigurationSourceChanged(configurationSource, mockLocator, testsSectionName);
        }
        /// <summary>
        /// Raise the <see cref="ContainerReconfiguring"/> event in response to a configuration source change.
        /// </summary>
        /// <param name="sender">Source of the event - the configuraton source.</param>
        /// <param name="e">Event arguments.</param>
        protected virtual void OnConfigurationSourceChanged(object sender, ConfigurationSourceChangedEventArgs e)
        {
            ContainerReconfiguringEventArgsImpl eventArgs =
                new ContainerReconfiguringEventArgsImpl(e.ConfigurationSource, e.ChangedSectionNames);

            lock (getUpdatedRegistrationsLock)
            {
                var handler = ContainerReconfiguring;
                if (handler != null)
                {
                    handler(this, eventArgs);
                }

                if (eventArgs.HasRegistrations)
                {
                    RegisterUpdates(eventArgs.Registrations);
                    eventSource.ConfigurationSourceChanged(e.ConfigurationSource, GetLocator(), e.ChangedSectionNames);
                }
            }
        }
        /// <summary>
        /// Raise the <see cref="ContainerReconfiguring"/> event in response to a configuration source change.
        /// </summary>
        /// <param name="sender">Source of the event - the configuraton source.</param>
        /// <param name="e">Event arguments.</param>
        protected virtual void OnConfigurationSourceChanged(object sender, ConfigurationSourceChangedEventArgs e)
        {
            ContainerReconfiguringEventArgsImpl eventArgs =
                new ContainerReconfiguringEventArgsImpl(e.ConfigurationSource, e.ChangedSectionNames);

            lock (getUpdatedRegistrationsLock)
            {
                var handler = ContainerReconfiguring;
                if (handler != null)
                {
                    handler(this, eventArgs);
                }

                if (eventArgs.HasRegistrations)
                {
                    RegisterUpdates(eventArgs.Registrations);
                    eventSource.ConfigurationSourceChanged(e.ConfigurationSource, GetLocator(), e.ChangedSectionNames);
                }
            }
        }
 void OnConfigurationSourceChanged(object sender, ConfigurationSourceChangedEventArgs args)
 {
     this.updatedSections = args.ChangedSectionNames;
 }
 private void OnRootConfigurationSourceChanged(object sender, ConfigurationSourceChangedEventArgs e)
 {
     sourceChangedEvent.Set();
 }
コード例 #9
0
 private void Configurator_OnConfigurationSourceChanged(object sender, ConfigurationSourceChangedEventArgs e)
 {
     sourceChangedEventArgs = e;
 }
コード例 #10
0
 void CompositeConfigurationSource_ConfigurationSourceChanged(object sender, ConfigurationSourceChangedEventArgs e)
 {
     DoSourceChanged(e.ChangedSectionNames);
 }
 void configurationSourcetoListenTo_SourceChanged(object sender, ConfigurationSourceChangedEventArgs e)
 {
     ConfigurationSourceChangedRaiseCount++;
     LastConfigurationSourceChangedEventArgs = e;
 }
 void OnConfigurationSourceChanged(object sender, ConfigurationSourceChangedEventArgs args)
 {
     this.updatedSections = args.ChangedSectionNames;
 }
 private void OnConfigurationChanged(object sender, ConfigurationSourceChangedEventArgs e)
 {
     MyInnerFoo = e.Container.GetInstance <IFoo>();
 }