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); }
public IEnumerable <Property> GetExtendedProperties(ElementViewModel subject) { var overriddenElementReference = overriddenElements.Where(x => x.ElementId == subject.ElementId).FirstOrDefault(); if (overriddenElementReference == null) { overriddenElementReference = new EnvironmentOverriddenElementReference(elementLookup, environmentSection); overriddenElementReference.InitializeWithElementViewModel(subject); overriddenElements.Add(overriddenElementReference); } Type environmentalOverriddenElementProperty = typeof(EnvironmentOverriddenElementProperty); var overridesAttribute = subject.Attributes.OfType <EnvironmentalOverridesAttribute>().FirstOrDefault(); if (overridesAttribute != null && overridesAttribute.CustomOverridesPropertyType != null) { environmentalOverriddenElementProperty = overridesAttribute.CustomOverridesPropertyType; } yield return(ContainingSection.CreateProperty(environmentalOverriddenElementProperty, new ParameterOverride("environmentModel", this), new ParameterOverride("subject", subject), new DependencyOverride <EnvironmentOverriddenElementPayload>(new InjectionParameter <EnvironmentOverriddenElementPayload>(overriddenElementReference.EnvironmentOverriddenElementPayload)))); }