本文整理汇总了C#中ConfigurationSaveMode类的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationSaveMode类的具体用法?C# ConfigurationSaveMode怎么用?C# ConfigurationSaveMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationSaveMode类属于命名空间,在下文中一共展示了ConfigurationSaveMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Unmerge
protected override void Unmerge(ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
{
RootProfilePropertySettingsCollection settingss = parentElement as RootProfilePropertySettingsCollection;
RootProfilePropertySettingsCollection settingss2 = sourceElement as RootProfilePropertySettingsCollection;
base.Unmerge(sourceElement, parentElement, saveMode);
this.GroupSettings.InternalUnMerge(settingss2.GroupSettings, (settingss != null) ? settingss.GroupSettings : null, saveMode);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:RootProfilePropertySettingsCollection.cs
示例2: SerializeSection
protected internal virtual string SerializeSection(ConfigurationElement parentElement, string name,
ConfigurationSaveMode saveMode)
{
if ((CurrentConfiguration != null) &&
(CurrentConfiguration.TargetFramework != null) &&
!ShouldSerializeSectionInTargetVersion(CurrentConfiguration.TargetFramework))
return string.Empty;
ValidateElement(this, null, true);
ConfigurationElement tempElement = CreateElement(GetType());
tempElement.Unmerge(this, parentElement, saveMode);
StringWriter strWriter = new StringWriter(CultureInfo.InvariantCulture);
XmlTextWriter writer = new XmlTextWriter(strWriter)
{
Formatting = Formatting.Indented,
Indentation = 4,
IndentChar = ' '
};
tempElement.DataToWriteInternal = saveMode != ConfigurationSaveMode.Minimal;
if ((CurrentConfiguration != null) && (CurrentConfiguration.TargetFramework != null))
_configRecord.SectionsStack.Push(this);
tempElement.SerializeToXmlElement(writer, name);
if ((CurrentConfiguration != null) && (CurrentConfiguration.TargetFramework != null))
_configRecord.SectionsStack.Pop();
writer.Flush();
return strWriter.ToString();
}
示例3: SerializeSection
protected override string SerializeSection(
ConfigurationElement parentElement,
string name, ConfigurationSaveMode saveMode)
{
string s =
base.SerializeSection(parentElement,name, saveMode);
return s;
}
示例4: SerializeSection
protected override string SerializeSection(
ConfigurationElement parentElement,
string name, ConfigurationSaveMode saveMode)
{
string s = base.SerializeSection(parentElement, name, saveMode);
// You can add custom processing code here.
return s;
}
示例5: SerializeSection
protected override string SerializeSection(ConfigurationElement parentElement,
string name,
ConfigurationSaveMode saveMode)
{
StringWriter stringWriter = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
XmlTextWriter textWriter = new XmlTextWriter(stringWriter);
serializer.Serialize(textWriter, Settings);
return stringWriter.ToString();
}
示例6: Unmerge
protected override void Unmerge(ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
{
base.Unmerge(sourceElement, parentElement, saveMode);
SwitchElement element = sourceElement as SwitchElement;
if ((element != null) && (element._attributes != null))
{
this._attributes = element._attributes;
}
}
示例7: SerializeSection
protected override string SerializeSection(ConfigurationElement parentElement, string name, ConfigurationSaveMode saveMode)
{
StringWriter sWriter = new StringWriter(CultureInfo.InvariantCulture);
XmlTextWriter xWriter = new XmlTextWriter(sWriter);
xWriter.Formatting = Formatting.Indented;
xWriter.Indentation = 4;
xWriter.IndentChar = ' ';
SerializeToXmlElement(xWriter, name);
xWriter.Flush();
return sWriter.ToString();
}
示例8: Unmerge
protected internal override void Unmerge(ConfigurationElement sourceElement,
ConfigurationElement parentElement,
ConfigurationSaveMode saveMode)
{
ProviderSettings parentProviders = parentElement as ProviderSettings;
parentProviders?.UpdatePropertyCollection(); // before reseting make sure the bag is filled in
ProviderSettings sourceProviders = sourceElement as ProviderSettings;
sourceProviders?.UpdatePropertyCollection(); // before reseting make sure the bag is filled in
base.Unmerge(sourceElement, parentElement, saveMode);
UpdatePropertyCollection();
}
示例9: SerializeSection
protected internal virtual string SerializeSection(ConfigurationElement parentElement, string name, ConfigurationSaveMode saveMode) {
ValidateElement(this, null, true);
ConfigurationElement TempElement = CreateElement(this.GetType());
TempElement.Unmerge(this, parentElement, saveMode);
StringWriter strWriter = new StringWriter(CultureInfo.InvariantCulture);
XmlTextWriter writer = new XmlTextWriter(strWriter);
writer.Formatting = Formatting.Indented;
writer.Indentation = 4;
writer.IndentChar = ' ';
TempElement.DataToWriteInternal = (saveMode != ConfigurationSaveMode.Minimal);
TempElement.SerializeToXmlElement(writer, name);
writer.Flush();
return strWriter.ToString();
}
示例10: SerializeSection
/// <summary>
/// Creates an XML string containing an unmerged view of the <see cref="ConfigurationSection" />
/// object as a single section to write to a file.
/// </summary>
/// <param name="parentElement">The <see cref="ConfigurationElement" />
/// instance to use as the parent when performing the un-merge.</param>
/// <param name="name">The name of the section to create.</param>
/// <param name="saveMode">The <see cref="ConfigurationSaveMode" /> instance
/// to use when writing to a string.</param>
/// <returns>
/// An XML string containing an unmerged view of the <see cref="ConfigurationSection" /> object.
/// </returns>
protected override string SerializeSection(ConfigurationElement parentElement, string name,
ConfigurationSaveMode saveMode)
{
IgniteArgumentCheck.NotNull(parentElement, "parentElement");
IgniteArgumentCheck.NotNullOrEmpty(name, "name");
if (IgniteConfiguration == null)
return string.Format("<{0} />", name);
var sb = new StringBuilder();
using (var xmlWriter = XmlWriter.Create(sb))
{
IgniteConfigurationXmlSerializer.Serialize(IgniteConfiguration, xmlWriter, name);
return sb.ToString();
}
}
示例11: ElementUnmerge
void ElementUnmerge (ConfigurationElement target, ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
{
target.GetType ().GetMethod ("Unmerge", BindingFlags.NonPublic | BindingFlags.Instance).Invoke (target, new object [] {sourceElement, parentElement, saveMode});
}
示例12: Unmerge
protected override void Unmerge (ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode)
{
if (parentElement != null && sourceElement.GetType() != parentElement.GetType())
throw new ConfigurationErrorsException ("Can't unmerge two elements of different type");
bool isMinimalOrModified = saveMode == ConfigurationSaveMode.Minimal ||
saveMode == ConfigurationSaveMode.Modified;
foreach (PropertyInformation prop in sourceElement.ElementInformation.Properties)
{
if (prop.ValueOrigin == PropertyValueOrigin.Default)
continue;
PropertyInformation unmergedProp = ElementInformation.Properties [prop.Name];
object sourceValue = prop.Value;
if (parentElement == null || !HasValue (parentElement, prop.Name)) {
unmergedProp.Value = sourceValue;
continue;
}
if (sourceValue == null)
continue;
object parentValue = GetItem (parentElement, prop.Name);
if (!PropertyIsElement (prop)) {
if (!object.Equals (sourceValue, parentValue) ||
(saveMode == ConfigurationSaveMode.Full) ||
(saveMode == ConfigurationSaveMode.Modified && prop.ValueOrigin == PropertyValueOrigin.SetHere))
unmergedProp.Value = sourceValue;
continue;
}
var sourceElem = (ConfigurationElement) sourceValue;
if (isMinimalOrModified && !ElementIsModified (sourceElem))
continue;
if (parentValue == null) {
unmergedProp.Value = sourceValue;
continue;
}
var parentElem = (ConfigurationElement) parentValue;
ConfigurationElement copy = (ConfigurationElement) unmergedProp.Value;
ElementUnmerge (copy, sourceElem, parentElem, saveMode);
}
}
示例13: HasValues
bool HasValues (ConfigurationSaveMode mode)
{
foreach (ConfigurationLocation loc in Locations) {
if (loc.OpenedConfiguration == null)
continue;
if (loc.OpenedConfiguration.HasValues (mode))
return true;
}
return rootGroup.HasValues (this, mode);
}
示例14: Save
void Save (Stream stream, ConfigurationSaveMode mode, bool forceUpdateAll)
{
XmlTextWriter tw = new XmlTextWriter (new StreamWriter (stream));
tw.Formatting = Formatting.Indented;
try {
tw.WriteStartDocument ();
if (rootNamespace != null)
tw.WriteStartElement ("configuration", rootNamespace);
else
tw.WriteStartElement ("configuration");
if (rootGroup.HasConfigContent (this)) {
rootGroup.WriteConfig (this, tw, mode);
}
foreach (ConfigurationLocation loc in Locations) {
if (loc.OpenedConfiguration == null) {
tw.WriteRaw ("\n");
tw.WriteRaw (loc.XmlContent);
}
else {
tw.WriteStartElement ("location");
tw.WriteAttributeString ("path", loc.Path);
if (!loc.AllowOverride)
tw.WriteAttributeString ("allowOverride", "false");
loc.OpenedConfiguration.SaveData (tw, mode, forceUpdateAll);
tw.WriteEndElement ();
}
}
SaveData (tw, mode, forceUpdateAll);
tw.WriteEndElement ();
ResetModified ();
}
finally {
tw.Flush ();
tw.Close ();
}
}
示例15: SaveAs
public void SaveAs (string filename, ConfigurationSaveMode mode)
{
SaveAs (filename, mode, false);
}