public OverriddenElementViewModel(ElementLookup lookup, EnvironmentMergeSection environmentSection, EnvironmentNodeMergeElement mergeElement)
 {
     this.lookup = lookup;
     this.environmentSection = environmentSection;
     this.mergeElement = mergeElement;
     this.elementReference = new ReferenceContainer(this);
     this.elementReference.InitializeReference(mergeElement.ConfigurationNodePath, mergeElement);
 }
 public OverriddenElementViewModel(ElementLookup lookup, EnvironmentMergeSection environmentSection, EnvironmentNodeMergeElement mergeElement)
 {
     this.lookup             = lookup;
     this.environmentSection = environmentSection;
     this.mergeElement       = mergeElement;
     this.elementReference   = new ReferenceContainer(this);
     this.elementReference.InitializeReference(mergeElement.ConfigurationNodePath, mergeElement);
 }
            public void InitializeReference(string elementPath, EnvironmentNodeMergeElement mergeElement)
            {
                this.mergeElement = mergeElement;
                this.mergeElement.ConfigurationNodePath = elementPath;

                elementReference = overrides.lookup.CreateReference(elementPath);
                elementReference.ElementDeleted += new EventHandler(elementReference_ElementDeleted);
                elementReference.ElementFound   += new EventHandler(elementReference_ElementFound);
                elementReference.PathChanged    += new PropertyValueChangedEventHandler <string>(ElementReferencePathChanged);

                needsInitialization = false;
            }
        public void SetOverrideProperties(ElementViewModel element, bool overrideProperties)
        {
            if (mergeElement == null)
            {
                mergeElement = new EnvironmentNodeMergeElement()
                {
                    ConfigurationNodePath = element.Path,
                    OverrideProperties    = overrideProperties
                };
                environmentSection.MergeElements.Add(mergeElement);

                this.elementReference.InitializeReference(element.Path, mergeElement);
            }
            else
            {
                mergeElement.OverrideProperties = overrideProperties;
            }
            OnPropertyChanged("OverrideProperties");
        }
        public void SetOverrideProperties(ElementViewModel element, bool overrideProperties)
        {
            if (mergeElement == null)
            {
                mergeElement = new EnvironmentNodeMergeElement()
                {
                    ConfigurationNodePath = element.Path,
                    OverrideProperties = overrideProperties
                };
                environmentSection.MergeElements.Add(mergeElement);

                this.elementReference.InitializeReference(element.Path, mergeElement);
            }
            else
            {
                mergeElement.OverrideProperties = overrideProperties;
            }
            OnPropertyChanged("OverrideProperties");
        }
Exemple #6
0
        private void CopyEnvironmentOverrides(EnvironmentMergeSection environmentMergeSection, Dictionary <string, ConfigurationNodeMergeData> mergeDataByPath, IConfigurationUIHierarchy configurationHierarchy)
        {
            foreach (string path in mergeDataByPath.Keys)
            {
                ConfigurationNodeMergeData mergeData = mergeDataByPath[path];

                EnvironmentNodeMergeElement mergeElement = new EnvironmentNodeMergeElement();
                mergeElement.ConfigurationNodePath = path;
                mergeElement.OverrideProperties    = mergeData.OverrideProperties;

                foreach (string propertyName in mergeData.AllPropertyNames)
                {
                    object propertyValue            = mergeData.GetPropertyValue(propertyName, typeof(string), null, configurationHierarchy);
                    string serializedRepresentation = SerializationUtility.SerializeToString(propertyValue, configurationHierarchy);

                    NameValueConfigurationElement keyValue = new NameValueConfigurationElement(propertyName, serializedRepresentation);
                    mergeElement.OverriddenProperties.Add(keyValue);
                }

                environmentMergeSection.MergeElements.Add(mergeElement);
            }
        }
            public void InitializeReference(string elementPath, EnvironmentNodeMergeElement mergeElement)
            {
                this.mergeElement = mergeElement;
                this.mergeElement.ConfigurationNodePath = elementPath;

                elementReference = overrides.lookup.CreateReference(elementPath);
                elementReference.ElementDeleted += new EventHandler(elementReference_ElementDeleted);
                elementReference.ElementFound += new EventHandler(elementReference_ElementFound);
                elementReference.PathChanged += new PropertyValueChangedEventHandler<string>(ElementReferencePathChanged);
                
                needsInitialization = false;
            }
        private void CopyEnvironmentOverrides(EnvironmentMergeSection environmentMergeSection, Dictionary<string, ConfigurationNodeMergeData> mergeDataByPath, IConfigurationUIHierarchy configurationHierarchy)
        {
            foreach (string path in mergeDataByPath.Keys)
            {
                ConfigurationNodeMergeData mergeData = mergeDataByPath[path];

                EnvironmentNodeMergeElement mergeElement = new EnvironmentNodeMergeElement();
                mergeElement.ConfigurationNodePath = path;
                mergeElement.OverrideProperties = mergeData.OverrideProperties;

                foreach (string propertyName in mergeData.AllPropertyNames)
                {
                    object propertyValue = mergeData.GetPropertyValue(propertyName, typeof(string), null, configurationHierarchy);
                    string serializedRepresentation = SerializationUtility.SerializeToString(propertyValue, configurationHierarchy);

                    NameValueConfigurationElement keyValue = new NameValueConfigurationElement(propertyName, serializedRepresentation);
                    mergeElement.OverriddenProperties.Add(keyValue);
                }

                environmentMergeSection.MergeElements.Add(mergeElement);
            }
        }