コード例 #1
0
        public EnvironmentSourceViewModel(IUnityContainer builder, IUIServiceWpf uiService, ApplicationViewModel sourceModel, ConfigurationSection section)
            : base(builder, EnvironmentalOverridesSection.EnvironmentallyOverriddenProperties, section, new Attribute[] { new EnvironmentalOverridesAttribute(false) })
        {
            this.uiService          = uiService;
            this.environmentSection = (EnvironmentalOverridesSection)section;
            this.elementLookup      = builder.Resolve <ElementLookup>();
            this.applicationModel   = sourceModel;

            foreach (EnvironmentalOverridesElement mergeElement in environmentSection.MergeElements)
            {
                var payload   = new EnvironmentOverriddenElementPayload(environmentSection, mergeElement.LogicalParentElementPath);
                var reference = new EnvironmentOverriddenElementReference(elementLookup, environmentSection);
                reference.InitializeWithConfigurationElementPayload(payload);

                overriddenElements.Add(reference);
            }

            saveMergedConfigurationCommand = CreateCommand <SaveMergedEnvironmentConfigurationCommand>(this);
            saveEnvironmentDeltaCommand    = CreateCommand <SaveEnvironmentConfigurationDeltaCommand>(this);
        }
        protected override void Arrange()
        {
            base.Arrange();

            ConfigurationSourceModel sourceModel = Container.Resolve<ConfigurationSourceModel>();

            sourceModel.AddSection(ConfigurationSourceSection.SectionName, new ConfigurationSourceSection()
            {
                SelectedSource = "file source",
                Sources = {{ new FileConfigurationSourceElement("file source", ".\\config") }}
            });

            exportMergedEnvironmentCommand = base.EnvironmentViewModel.Commands.OfType<SaveMergedEnvironmentConfigurationCommand>().First();

            base.UIServiceMock.Setup(x => x.ShowMessageWpf(It.IsRegex("File Configuration Source"), It.IsAny<string>(), MessageBoxButton.OK))
                .Returns(MessageBoxResult.OK)
                .Verifiable();
        }