protected override void Arrange() { cloner = new ConfigurationSectionCloner(); section = new TestConfigurationSection(); section.Custom.Name = "custom"; section.Custom.Attributes.Add("k1", "v1"); section.Custom.Attributes.Add("k2", "v2"); }
protected override void Act() { base.Act(); var cloner = new ConfigurationSectionCloner(); clonedSection = (UnityConfigurationSection)cloner.Clone(Section); }
public System.Configuration.ConfigurationElement CreateFullClone() { PropertyElement target = new PropertyElement(); PropertyElement clonedProperty = (PropertyElement)ConfigurationSectionCloner.CloneElement(propertyToClone, target); clonedProperty.Value = propertyToClone.Value; return(clonedProperty); }
protected override void Arrange() { base.Arrange(); var configurationFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "unity.config"); var source = new FileConfigurationSource(configurationFilePath); sectionToClone = (UnityConfigurationSection)source.GetSection("unity"); //editableSection = (UnityConfigurationSection)base.UnitySectionViewModel.ConfigurationElement; //editableSection.TypeAliases.Add(new AliasElement("alias1", typeof(int))); //editableSection.TypeAliases.Add(new AliasElement("alias2", typeof(string))); //editableSection.Containers.Add(new ContainerElement() //{ // Name = "cloned", // Registrations = {{ // new RegisterElement // { // Name = "Registration1", // TypeName = "RegistrationTypeName", // InjectionMembers = {{ // new PropertyElement // { // Name = "Property1", // Value = new ValueElement // { // Value = "PropertyValue" // } // } // }, // { // new ConstructorElement // { // Parameters = // {{ // new ParameterElement // { // Name = "array", // Value = new ArrayElement // { // TypeName = "t", // Values = {{new ArrayElement()},{new ValueElement // { // Value = "v" // }}} // } // } // }} // } // }} // }}} //}); cloner = new ConfigurationSectionCloner(); }
public System.Configuration.ConfigurationElement CreateFullClone() { AliasElement target = new AliasElement(); AliasElement clonedAlias = (AliasElement)ConfigurationSectionCloner.CloneElement(aliasToClone, target); clonedAlias.Alias = aliasToClone.Alias; return(clonedAlias); }
protected void ProtectSection(FileConfigurationSource source, string sectionName, string protectionProvider) { ConfigurationSectionCloner cloner = new ConfigurationSectionCloner(); var section = source.GetSection(sectionName); section = cloner.Clone(section); source.Remove(sectionName); source.Add(sectionName, section, protectionProvider); }
public virtual void Save(IDesignConfigurationSource configurationSource) { Guard.ArgumentNotNull(configurationSource, "configurationSource"); ConfigurationSectionCloner cloner = new ConfigurationSectionCloner(); var savableSection = cloner.Clone((ConfigurationSection)ConfigurationElement); BeforeSave(savableSection); configurationSource.RemoveLocalSection(configurationSectionName); if (protectionProviderProperty.NeedsProtectionProvider) { configurationSource.Add(configurationSectionName, savableSection, protectionProviderProperty.TypedValue); } else { configurationSource.AddLocalSection(configurationSectionName, savableSection); } }