当前位置: 首页>>代码示例>>C#>>正文


C# XmlUtilWriter.AppendSpacesToLinePosition方法代码示例

本文整理汇总了C#中System.Configuration.XmlUtilWriter.AppendSpacesToLinePosition方法的典型用法代码示例。如果您正苦于以下问题:C# XmlUtilWriter.AppendSpacesToLinePosition方法的具体用法?C# XmlUtilWriter.AppendSpacesToLinePosition怎么用?C# XmlUtilWriter.AppendSpacesToLinePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Configuration.XmlUtilWriter的用法示例。


在下文中一共展示了XmlUtilWriter.AppendSpacesToLinePosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyConfigDeclarationsRecursive

        private bool CopyConfigDeclarationsRecursive(
                SectionUpdates declarationUpdates, XmlUtil xmlUtil, XmlUtilWriter utilWriter, string group,
                int parentLinePosition, int parentIndent) {

            bool wroteASection = false;
            XmlTextReader reader = xmlUtil.Reader;
            int linePosition;
            int indent;
            int startingLinePosition;

            indent = UpdateIndent(parentIndent, xmlUtil, utilWriter, parentLinePosition);

            if (reader.NodeType == XmlNodeType.Element) {
                linePosition = xmlUtil.TrueLinePosition;
                startingLinePosition = linePosition;
            }
            else if (reader.NodeType == XmlNodeType.EndElement) {
                linePosition = parentLinePosition + indent;
                if (utilWriter.IsLastLineBlank) {
                    startingLinePosition = xmlUtil.TrueLinePosition;
                }
                else {
                    startingLinePosition = parentLinePosition;
                }
            }
            else {
                linePosition = parentLinePosition + indent;
                startingLinePosition = 0;
            }

            //
            // Write any new section declarations that apply to this group
            //
            if (declarationUpdates != null) {
                string[] movedSectionNames = declarationUpdates.GetMovedSectionNames();
                if (movedSectionNames != null) {
                    if (!utilWriter.IsLastLineBlank) {
                        utilWriter.AppendNewLine();
                    }

                    foreach (string configKey in movedSectionNames) {
                        DeclarationUpdate sectionUpdate = declarationUpdates.GetDeclarationUpdate(configKey);
                        Debug.Assert(!IsImplicitSection(configKey), "We should never write out an implicit section");

                        // Write the one line section declaration.
                        utilWriter.AppendSpacesToLinePosition(linePosition);
                        utilWriter.Write(sectionUpdate.UpdatedXml);
                        utilWriter.AppendNewLine();

                        wroteASection = true;
                    }

                    // Restore the whitespace we used for the first element, which is either a start or an end element.
                    utilWriter.AppendSpacesToLinePosition(startingLinePosition);
                }
            }

            if (reader.NodeType == XmlNodeType.Element) {
                //
                // For each element at this depth, either:
                // - Write the element verbatim and recurse due to a group hierarchy element.
                // - Write the element verbatim because it is unchanged
                // - Write the updated XML for the section.
                // - Skip it because the section has been removed.
                //
                int depth = reader.Depth;
                while (reader.Depth == depth) {
                    bool                recurse = false;
                    DeclarationUpdate   sectionUpdate = null;
                    DeclarationUpdate   groupUpdate = null;
                    SectionUpdates      declarationUpdatesChild = null;
                    SectionUpdates      recurseDeclarationUpdates = declarationUpdates;
                    string              recurseGroup = group;

                    // update the lineposition and indent for each element
                    indent = UpdateIndent(indent, xmlUtil, utilWriter, parentLinePosition);
                    linePosition = xmlUtil.TrueLinePosition;

                    string directive = reader.Name;
                    string name = reader.GetAttribute(KEYWORD_SECTIONGROUP_NAME);
                    string configKey = CombineConfigKey(group, name);
                    if (directive == KEYWORD_SECTIONGROUP) {
                        // it's a group - get the updates for children
                        declarationUpdatesChild = declarationUpdates.GetSectionUpdatesForGroup(name);
                        if (declarationUpdatesChild != null) {
                            // get the group update
                            groupUpdate = declarationUpdatesChild.GetSectionGroupUpdate();

                            // recurse if there are more sections to copy
                            if (declarationUpdatesChild.HasUnretrievedSections()) {
                                recurse = true;
                                recurseGroup = configKey;
                                recurseDeclarationUpdates = declarationUpdatesChild;
                            }
                        }
                    }
                    else {
                        // it is a section - get the update
                        Debug.Assert(!IsImplicitSection(configKey), "We should never write out an implicit section");
                        sectionUpdate = declarationUpdates.GetDeclarationUpdate(configKey);
//.........这里部分代码省略.........
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:101,代码来源:MgmtConfigurationRecord.cs

示例2: CopyConfigDefinitionsRecursive

        // Copy configuration sections from the original configuration file.
        private bool CopyConfigDefinitionsRecursive(
                ConfigDefinitionUpdates configDefinitionUpdates, XmlUtil xmlUtil, XmlUtilWriter utilWriter,
                bool locationPathApplies, LocationUpdates locationUpdates, SectionUpdates sectionUpdates,
                bool addNewSections, string group, int parentLinePosition, int parentIndent) {

            bool wroteASection = false;
            XmlTextReader reader = xmlUtil.Reader;
            int linePosition;
            int indent;
            int startingLinePosition;

            indent = UpdateIndent(parentIndent, xmlUtil, utilWriter, parentLinePosition);

            if (reader.NodeType == XmlNodeType.Element) {
                linePosition = xmlUtil.TrueLinePosition;
                startingLinePosition = linePosition;
            }
            else if (reader.NodeType == XmlNodeType.EndElement) {
                linePosition = parentLinePosition + indent;
                if (utilWriter.IsLastLineBlank) {
                    startingLinePosition = xmlUtil.TrueLinePosition;
                }
                else {
                    startingLinePosition = parentLinePosition;
                }
            }
            else {
                linePosition = parentLinePosition + indent;
                startingLinePosition = 0;
            }

            //
            // Write any new sections that apply to this group
            //
            if (sectionUpdates != null && addNewSections) {
                // Remove newness, so we won't write again
                sectionUpdates.IsNew = false;

                Debug.Assert(locationPathApplies, "locationPathApplies");
                string[] movedSectionNames = sectionUpdates.GetMovedSectionNames();
                if (movedSectionNames != null) {
                    if (!utilWriter.IsLastLineBlank) {
                        utilWriter.AppendNewLine();
                    }

                    utilWriter.AppendSpacesToLinePosition(linePosition);
                    bool skipFirstIndent = true;

                    foreach (string configKey in movedSectionNames) {
                        DefinitionUpdate update = sectionUpdates.GetDefinitionUpdate(configKey);

                        WriteSectionUpdate(utilWriter, update, linePosition, indent, skipFirstIndent);
                        skipFirstIndent = false;
                        utilWriter.AppendNewLine();
                        wroteASection = true;
                    }

                    // Restore the whitespace we used for the first element, which is either a start or an end element.
                    utilWriter.AppendSpacesToLinePosition(startingLinePosition);
                }
            }

            if (reader.NodeType == XmlNodeType.Element) {
                //
                // For each element at this depth, either:
                // - Write the element verbatim and recurse due to a location section or group hierarchy element.
                // - Write the element verbatim because it is unchanged, or because the current location does
                //   not apply.
                // - Write the updated XML for the section.
                // - Skip it because the section has been removed.
                //
                int depth = reader.Depth;
                while (reader.Depth == depth) {
                    bool                recurse = false;
                    DefinitionUpdate    update = null;
                    bool                elementLocationPathApplies = locationPathApplies;
                    LocationUpdates     recurseLocationUpdates = locationUpdates;
                    SectionUpdates      recurseSectionUpdates = sectionUpdates;
                    bool                recurseAddNewSections = addNewSections;
                    string              recurseGroup = group;
                    bool                removedSectionOrGroup = false;

                    // update the lineposition and indent for each element
                    indent = UpdateIndent(indent, xmlUtil, utilWriter, parentLinePosition);
                    linePosition = xmlUtil.TrueLinePosition;

                    string elementName = reader.Name;
                    if (elementName == KEYWORD_LOCATION) {
                        string locationSubPathAttribute = reader.GetAttribute(KEYWORD_LOCATION_PATH);
                        locationSubPathAttribute = NormalizeLocationSubPath(locationSubPathAttribute, xmlUtil);
                        elementLocationPathApplies = false;
                        OverrideModeSetting overrideMode = OverrideModeSetting.LocationDefault;
                        bool inheritInChildApps = true;

                        if (IsLocationConfig) {
                            // For location config we will compare config paths instead of location strings
                            // so that we dont end up comparing "1" with "Default Web Site" and ending up with the wrong result
                            if (locationSubPathAttribute == null) {
                                elementLocationPathApplies = false;
//.........这里部分代码省略.........
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:101,代码来源:MgmtConfigurationRecord.cs

示例3: WriteNewConfigDefinitionsRecursive

        // Recursively write new sections for each section group.
        private bool WriteNewConfigDefinitionsRecursive(XmlUtilWriter utilWriter, SectionUpdates sectionUpdates, int linePosition, int indent, bool skipFirstIndent) {
            bool wroteASection = false;

            string[] movedSectionNames = sectionUpdates.GetMovedSectionNames();
            if (movedSectionNames != null) {
                wroteASection = true;
                foreach (string configKey in movedSectionNames) {
                    DefinitionUpdate update = sectionUpdates.GetDefinitionUpdate(configKey);
                    WriteSectionUpdate(utilWriter, update, linePosition, indent, skipFirstIndent);
                    utilWriter.AppendNewLine();
                    skipFirstIndent = false;
                }
            }

            string[] newGroupNames = sectionUpdates.GetNewGroupNames();
            if (newGroupNames != null) {
                foreach (string group in newGroupNames) {

                    if (TargetFramework != null) {
                        ConfigurationSectionGroup g = GetSectionGroup(group);
                        if (g != null && !g.ShouldSerializeSectionGroupInTargetVersion(TargetFramework)){
                            sectionUpdates.MarkGroupAsRetrieved(group);
                            continue;
                        }
                    }

                    if (!skipFirstIndent) {
                        utilWriter.AppendSpacesToLinePosition(linePosition);
                    }
                    skipFirstIndent = false;

                    utilWriter.Write("<" + group + ">\r\n");
                    bool recurseWroteASection = WriteNewConfigDefinitionsRecursive(
                            utilWriter, sectionUpdates.GetSectionUpdatesForGroup(group), linePosition + indent, indent, false);

                    if (recurseWroteASection) {
                        wroteASection = true;
                    }

                    utilWriter.AppendSpacesToLinePosition(linePosition);
                    utilWriter.Write("</" + group + ">\r\n");
                }
            }

            sectionUpdates.IsNew = false;

            return wroteASection;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:49,代码来源:MgmtConfigurationRecord.cs

示例4: CopyConfig

        // Copy a config file, replacing sections with updates.
        private void CopyConfig(SectionUpdates declarationUpdates, ConfigDefinitionUpdates definitionUpdates,
                byte[] buffer, string filename, NamespaceChange namespaceChange, XmlUtilWriter utilWriter) {

            CheckPreamble(ConfigStreamInfo.StreamEncoding.GetPreamble(), utilWriter, buffer);

            using (Stream stream = new MemoryStream(buffer)) {
                using (XmlUtil xmlUtil = new XmlUtil(stream, filename, false)) {
                    // copy up to the <configuration> node
                    XmlTextReader reader = xmlUtil.Reader;
                    reader.WhitespaceHandling = WhitespaceHandling.All;
                    reader.Read();
                    xmlUtil.CopyReaderToNextElement(utilWriter, false);

                    Debug.Assert(reader.NodeType == XmlNodeType.Element && reader.Name == KEYWORD_CONFIGURATION,
                                 "reader.NodeType == XmlNodeType.Element && reader.Name == KEYWORD_CONFIGURATION");

                    int indent = DEFAULT_INDENT;
                    int configurationElementLinePosition = xmlUtil.TrueLinePosition;
                    bool isEmptyConfigurationElement = reader.IsEmptyElement;

                    // copy <configuration> node
                    // if the node is an empty element, we may need to open it.
                    string configurationStartElement;
                    if (namespaceChange == NamespaceChange.Add) {
                        configurationStartElement = string.Format(
                            CultureInfo.InvariantCulture, FORMAT_CONFIGURATION_NAMESPACE, KEYWORD_CONFIGURATION_NAMESPACE);
                    }
                    else if (namespaceChange == NamespaceChange.Remove) {
                        configurationStartElement = FORMAT_CONFIGURATION;
                    }
                    else {
                        configurationStartElement = null;
                    }

                    bool needsChildren = (declarationUpdates != null || definitionUpdates  != null);
                    string configurationEndElement = xmlUtil.UpdateStartElement(utilWriter, configurationStartElement, needsChildren, configurationElementLinePosition, indent);

                    bool foundConfigSectionsElement = false;
                    if (!isEmptyConfigurationElement) {
                        // copy up to the first element under <configuration>
                        xmlUtil.CopyReaderToNextElement(utilWriter, true);

                        // updateIndent
                        indent = UpdateIndent(indent, xmlUtil, utilWriter, configurationElementLinePosition);

                        if (reader.NodeType == XmlNodeType.Element && reader.Name == KEYWORD_CONFIGSECTIONS) {
                            foundConfigSectionsElement = true;

                            int configSectionsElementLinePosition = xmlUtil.TrueLinePosition;
                            bool isEmptyConfigSectionsElement = reader.IsEmptyElement;

                            // if no updates, copy the entire <configSections> element
                            if (declarationUpdates == null) {
                                xmlUtil.CopyOuterXmlToNextElement(utilWriter, true);
                            }
                            else {
                                // copy <configSections>, and open it if it is an empty element
                                string configSectionsEndElement = xmlUtil.UpdateStartElement(
                                    utilWriter, null, true, configSectionsElementLinePosition, indent);

                                if (!isEmptyConfigSectionsElement) {
                                    // copy to next element under <configSections>, or up to closing </configSections>
                                    xmlUtil.CopyReaderToNextElement(utilWriter, true);

                                    // copy config declarations
                                    CopyConfigDeclarationsRecursive(declarationUpdates, xmlUtil, utilWriter, string.Empty,
                                            configSectionsElementLinePosition, indent);

                                    Debug.Assert(reader.NodeType == XmlNodeType.EndElement && reader.Name == KEYWORD_CONFIGSECTIONS,
                                                 "reader.NodeType == XmlNodeType.EndElement && reader.Name == \"KEYWORD_CONFIGSECTIONS\"");
                                }

                                // write declarations not written by above copy
                                if (declarationUpdates.HasUnretrievedSections()) {

                                    // determine the line position of the end element
                                    int endElementLinePosition = 0;
                                    if (configSectionsEndElement == null) {
                                        endElementLinePosition = xmlUtil.TrueLinePosition;
                                    }

                                    // indent a new line
                                    if (!utilWriter.IsLastLineBlank) {
                                        utilWriter.AppendNewLine();
                                    }

                                    WriteUnwrittenConfigDeclarations(declarationUpdates, utilWriter, configSectionsElementLinePosition + indent, indent, false);

                                    // restore spaces to end element
                                    if (configSectionsEndElement == null) {
                                        utilWriter.AppendSpacesToLinePosition(endElementLinePosition);
                                    }
                                }

                                // Copy the </configSections> element
                                if (configSectionsEndElement == null) {
                                    xmlUtil.CopyXmlNode(utilWriter);
                                }
                                else {
//.........这里部分代码省略.........
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:101,代码来源:MgmtConfigurationRecord.cs

示例5: WriteUnwrittenConfigDeclarationsRecursive

        private void WriteUnwrittenConfigDeclarationsRecursive(SectionUpdates declarationUpdates, XmlUtilWriter utilWriter, int linePosition, int indent, bool skipFirstIndent) {
            string[] unretrievedSectionNames = declarationUpdates.GetUnretrievedSectionNames();
            if (unretrievedSectionNames != null) {
                foreach (string configKey in unretrievedSectionNames) {
                    Debug.Assert(!IsImplicitSection(configKey), "We should never write out an implicit section");
                    if (!skipFirstIndent) {
                        utilWriter.AppendSpacesToLinePosition(linePosition);
                    }
                    skipFirstIndent = false;

                    DeclarationUpdate update = declarationUpdates.GetDeclarationUpdate(configKey);
                    if (update != null && !string.IsNullOrEmpty(update.UpdatedXml)) {
                        utilWriter.Write(update.UpdatedXml);
                        utilWriter.AppendNewLine();
                    }
                }
            }

            string[] unretrievedGroupNames = declarationUpdates.GetUnretrievedGroupNames();
            if (unretrievedGroupNames != null) {
                foreach (string group in unretrievedGroupNames) {
                    if (TargetFramework != null) {
                        ConfigurationSectionGroup g = GetSectionGroup(group);
                        if (g != null && !g.ShouldSerializeSectionGroupInTargetVersion(TargetFramework)){
                            declarationUpdates.MarkGroupAsRetrieved(group);
                            continue;
                        }
                    }
                    if (!skipFirstIndent) {
                        utilWriter.AppendSpacesToLinePosition(linePosition);
                    }
                    skipFirstIndent = false;

                    SectionUpdates declarationUpdatesChild = declarationUpdates.GetSectionUpdatesForGroup(group);
                    DeclarationUpdate groupUpdate = declarationUpdatesChild.GetSectionGroupUpdate();
                    if (groupUpdate == null) {
                        utilWriter.Write("<sectionGroup name=\"" + group + "\">");
                    }
                    else {
                        utilWriter.Write(groupUpdate.UpdatedXml);
                    }
                    utilWriter.AppendNewLine();

                    WriteUnwrittenConfigDeclarationsRecursive(declarationUpdatesChild, utilWriter, linePosition + indent, indent, false);
                    utilWriter.AppendSpacesToLinePosition(linePosition);
                    utilWriter.Write("</sectionGroup>\r\n");
                }
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:49,代码来源:MgmtConfigurationRecord.cs

示例6: WriteNewConfigDefinitions

        private void WriteNewConfigDefinitions(ConfigDefinitionUpdates configDefinitionUpdates, XmlUtilWriter utilWriter, int linePosition, int indent) {
            if (configDefinitionUpdates == null)
                return;

            foreach (LocationUpdates locationUpdates in configDefinitionUpdates.LocationUpdatesList) {
                SectionUpdates sectionUpdates = locationUpdates.SectionUpdates;
                if (sectionUpdates.IsEmpty || !sectionUpdates.IsNew)
                    continue;

                configDefinitionUpdates.FlagLocationWritten();
                bool writeLocationTag = _locationSubPath != null || !locationUpdates.IsDefault;
                int recurseLinePosition = linePosition;

                utilWriter.AppendSpacesToLinePosition(linePosition);

                if (writeLocationTag) {
                    // write the <location> start tag
                    if (_locationSubPath == null) {
                        utilWriter.Write(String.Format(CultureInfo.InvariantCulture, FORMAT_LOCATION_NOPATH, locationUpdates.OverrideMode.LocationTagXmlString, BoolToString(locationUpdates.InheritInChildApps)));
                    }
                    else {
                        utilWriter.Write(String.Format(CultureInfo.InvariantCulture, FORMAT_LOCATION_PATH, locationUpdates.OverrideMode.LocationTagXmlString, BoolToString(locationUpdates.InheritInChildApps), _locationSubPath));
                    }

                    recurseLinePosition += indent;
                    utilWriter.AppendSpacesToLinePosition(recurseLinePosition);
                }

                // Invoke the recursive write.
                WriteNewConfigDefinitionsRecursive(utilWriter, locationUpdates.SectionUpdates, recurseLinePosition, indent, true);

                if (writeLocationTag) {
                    // Write the location end tag
                    utilWriter.AppendSpacesToLinePosition(linePosition);
                    utilWriter.Write(FORMAT_LOCATION_ENDELEMENT);
                    utilWriter.AppendNewLine();
                }
            }

            if (configDefinitionUpdates.RequireLocation) {
                Debug.Assert(IsLocationConfig, "IsLocationConfig");

                // If we still require this to be written, then we must write it out now
                configDefinitionUpdates.FlagLocationWritten();

                utilWriter.AppendSpacesToLinePosition(linePosition);

                utilWriter.Write(String.Format(CultureInfo.InvariantCulture, FORMAT_LOCATION_PATH, OverrideModeSetting.LocationDefault.LocationTagXmlString, KEYWORD_TRUE, _locationSubPath));
                utilWriter.AppendSpacesToLinePosition(linePosition);
                utilWriter.Write(FORMAT_LOCATION_ENDELEMENT);
                utilWriter.AppendNewLine();
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:53,代码来源:MgmtConfigurationRecord.cs

示例7: SkipChildElementsAndCopyOuterXmlToNextElement

        //
        // Copy an XML element but skip all its child elements, then continue copying until we've hit the next element.
        //
        internal bool SkipChildElementsAndCopyOuterXmlToNextElement(XmlUtilWriter utilWriter) {
            bool    isEmptyElement = _reader.IsEmptyElement;
            int     startingLine = _reader.LineNumber;
#if DBG
            int     depth = _reader.Depth;
#endif

            Debug.Assert(_reader.NodeType == XmlNodeType.Element, "_reader.NodeType == XmlNodeType.Element");

            CopyXmlNode(utilWriter);

            // See if we need to skip any child element
            if (!isEmptyElement) {
                while (_reader.NodeType != XmlNodeType.EndElement) {
                    
                    // Skip all the inner child elements
                    if (_reader.NodeType == XmlNodeType.Element) {
                        _reader.Skip();

                        // We need to skip all the whitespaces following a skipped element.
                        // - If the whitespaces don't contain /r/n, then it's okay to skip them 
                        //   as part of the element.
                        // - If the whitespaces contain /r/n, not skipping them will result
                        //   in a redundant emtpy line being copied.
                        if (_reader.NodeType == XmlNodeType.Whitespace) {
                            _reader.Skip();
                        }
                    }
                    else {
                        // We want to preserve other content, e.g. comments.
                        CopyXmlNode(utilWriter);
                    }
                }

                if (_reader.LineNumber != startingLine) {
                    // The whitespace in front of the EndElement was skipped above.
                    // We need to append spaces to compensate for that.
                    utilWriter.AppendSpacesToLinePosition(TrueLinePosition);
                }


#if DBG                
                Debug.Assert(_reader.Depth == depth, "We should be at the same depth as the opening Element");
#endif
                    
                // Copy the end element.
                CopyXmlNode(utilWriter);
            }                

            return CopyReaderToNextElement(utilWriter, true);
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:54,代码来源:xmlutil.cs

示例8: WriteNewConfigDeclarations

        private void WriteNewConfigDeclarations(SectionUpdates declarationUpdates, XmlUtilWriter utilWriter, int linePosition, int indent, bool skipFirstIndent) {
            if (!skipFirstIndent) {
                utilWriter.AppendSpacesToLinePosition(linePosition);
            }

            utilWriter.Write("<configSections>\r\n");
            WriteUnwrittenConfigDeclarations(declarationUpdates, utilWriter, linePosition + indent, indent, false);
            utilWriter.AppendSpacesToLinePosition(linePosition);
            utilWriter.Write("</configSections>\r\n");

            if (skipFirstIndent) {
                utilWriter.AppendSpacesToLinePosition(linePosition);
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:14,代码来源:MgmtConfigurationRecord.cs

示例9: CopyConfigDefinitionsRecursive

 private bool CopyConfigDefinitionsRecursive(ConfigDefinitionUpdates configDefinitionUpdates, XmlUtil xmlUtil, XmlUtilWriter utilWriter, bool locationPathApplies, LocationUpdates locationUpdates, SectionUpdates sectionUpdates, bool addNewSections, string group, int parentLinePosition, int parentIndent)
 {
     int trueLinePosition;
     int num3;
     bool flag = false;
     XmlTextReader reader = xmlUtil.Reader;
     int indent = this.UpdateIndent(parentIndent, xmlUtil, utilWriter, parentLinePosition);
     if (reader.NodeType == XmlNodeType.Element)
     {
         trueLinePosition = xmlUtil.TrueLinePosition;
         num3 = trueLinePosition;
     }
     else if (reader.NodeType == XmlNodeType.EndElement)
     {
         trueLinePosition = parentLinePosition + indent;
         if (utilWriter.IsLastLineBlank)
         {
             num3 = xmlUtil.TrueLinePosition;
         }
         else
         {
             num3 = parentLinePosition;
         }
     }
     else
     {
         trueLinePosition = parentLinePosition + indent;
         num3 = 0;
     }
     if ((sectionUpdates != null) && addNewSections)
     {
         sectionUpdates.IsNew = false;
         string[] movedSectionNames = sectionUpdates.GetMovedSectionNames();
         if (movedSectionNames != null)
         {
             if (!utilWriter.IsLastLineBlank)
             {
                 utilWriter.AppendNewLine();
             }
             utilWriter.AppendSpacesToLinePosition(trueLinePosition);
             bool skipFirstIndent = true;
             foreach (string str in movedSectionNames)
             {
                 DefinitionUpdate definitionUpdate = sectionUpdates.GetDefinitionUpdate(str);
                 this.WriteSectionUpdate(utilWriter, definitionUpdate, trueLinePosition, indent, skipFirstIndent);
                 skipFirstIndent = false;
                 utilWriter.AppendNewLine();
                 flag = true;
             }
             utilWriter.AppendSpacesToLinePosition(num3);
         }
     }
     if (reader.NodeType == XmlNodeType.Element)
     {
         int depth = reader.Depth;
         while (reader.Depth == depth)
         {
             bool flag3 = false;
             DefinitionUpdate update = null;
             bool flag4 = locationPathApplies;
             LocationUpdates updates = locationUpdates;
             SectionUpdates updates2 = sectionUpdates;
             bool flag5 = addNewSections;
             string str2 = group;
             bool flag6 = false;
             indent = this.UpdateIndent(indent, xmlUtil, utilWriter, parentLinePosition);
             trueLinePosition = xmlUtil.TrueLinePosition;
             string name = reader.Name;
             if (name == "location")
             {
                 string locationSubPath = BaseConfigurationRecord.NormalizeLocationSubPath(reader.GetAttribute("path"), xmlUtil);
                 flag4 = false;
                 OverrideModeSetting locationDefault = OverrideModeSetting.LocationDefault;
                 bool inheritInChildApps = true;
                 if (base.IsLocationConfig)
                 {
                     if (locationSubPath == null)
                     {
                         flag4 = false;
                     }
                     else
                     {
                         flag4 = StringUtil.EqualsIgnoreCase(base.ConfigPath, base.Host.GetConfigPathFromLocationSubPath(base.Parent.ConfigPath, locationSubPath));
                     }
                 }
                 else
                 {
                     flag4 = locationSubPath == null;
                 }
                 if (flag4)
                 {
                     string attribute = reader.GetAttribute("allowOverride");
                     if (attribute != null)
                     {
                         locationDefault = OverrideModeSetting.CreateFromXmlReadValue(bool.Parse(attribute));
                     }
                     string str6 = reader.GetAttribute("overrideMode");
                     if (str6 != null)
                     {
                         locationDefault = OverrideModeSetting.CreateFromXmlReadValue(OverrideModeSetting.ParseOverrideModeXmlValue(str6, null));
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:MgmtConfigurationRecord.cs

示例10: SkipChildElementsAndCopyOuterXmlToNextElement

 internal bool SkipChildElementsAndCopyOuterXmlToNextElement(XmlUtilWriter utilWriter)
 {
     bool isEmptyElement = this._reader.IsEmptyElement;
     int lineNumber = this._reader.LineNumber;
     this.CopyXmlNode(utilWriter);
     if (!isEmptyElement)
     {
         while (this._reader.NodeType != XmlNodeType.EndElement)
         {
             if (this._reader.NodeType == XmlNodeType.Element)
             {
                 this._reader.Skip();
                 if (this._reader.NodeType == XmlNodeType.Whitespace)
                 {
                     this._reader.Skip();
                 }
             }
             else
             {
                 this.CopyXmlNode(utilWriter);
             }
         }
         if (this._reader.LineNumber != lineNumber)
         {
             utilWriter.AppendSpacesToLinePosition(this.TrueLinePosition);
         }
         this.CopyXmlNode(utilWriter);
     }
     return this.CopyReaderToNextElement(utilWriter, true);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:XmlUtil.cs

示例11: CopyConfigDeclarationsRecursive

 private bool CopyConfigDeclarationsRecursive(SectionUpdates declarationUpdates, XmlUtil xmlUtil, XmlUtilWriter utilWriter, string group, int parentLinePosition, int parentIndent)
 {
     int trueLinePosition;
     int num3;
     bool flag = false;
     XmlTextReader reader = xmlUtil.Reader;
     int oldIndent = this.UpdateIndent(parentIndent, xmlUtil, utilWriter, parentLinePosition);
     if (reader.NodeType == XmlNodeType.Element)
     {
         trueLinePosition = xmlUtil.TrueLinePosition;
         num3 = trueLinePosition;
     }
     else if (reader.NodeType == XmlNodeType.EndElement)
     {
         trueLinePosition = parentLinePosition + oldIndent;
         if (utilWriter.IsLastLineBlank)
         {
             num3 = xmlUtil.TrueLinePosition;
         }
         else
         {
             num3 = parentLinePosition;
         }
     }
     else
     {
         trueLinePosition = parentLinePosition + oldIndent;
         num3 = 0;
     }
     if (declarationUpdates != null)
     {
         string[] movedSectionNames = declarationUpdates.GetMovedSectionNames();
         if (movedSectionNames != null)
         {
             if (!utilWriter.IsLastLineBlank)
             {
                 utilWriter.AppendNewLine();
             }
             foreach (string str in movedSectionNames)
             {
                 DeclarationUpdate declarationUpdate = declarationUpdates.GetDeclarationUpdate(str);
                 utilWriter.AppendSpacesToLinePosition(trueLinePosition);
                 utilWriter.Write(declarationUpdate.UpdatedXml);
                 utilWriter.AppendNewLine();
                 flag = true;
             }
             utilWriter.AppendSpacesToLinePosition(num3);
         }
     }
     if (reader.NodeType == XmlNodeType.Element)
     {
         int depth = reader.Depth;
         while (reader.Depth == depth)
         {
             bool flag2 = false;
             DeclarationUpdate update2 = null;
             DeclarationUpdate sectionGroupUpdate = null;
             SectionUpdates sectionUpdatesForGroup = null;
             SectionUpdates updates2 = declarationUpdates;
             string str2 = group;
             oldIndent = this.UpdateIndent(oldIndent, xmlUtil, utilWriter, parentLinePosition);
             trueLinePosition = xmlUtil.TrueLinePosition;
             string name = reader.Name;
             string attribute = reader.GetAttribute("name");
             string configKey = BaseConfigurationRecord.CombineConfigKey(group, attribute);
             if (name == "sectionGroup")
             {
                 sectionUpdatesForGroup = declarationUpdates.GetSectionUpdatesForGroup(attribute);
                 if (sectionUpdatesForGroup != null)
                 {
                     sectionGroupUpdate = sectionUpdatesForGroup.GetSectionGroupUpdate();
                     if (sectionUpdatesForGroup.HasUnretrievedSections())
                     {
                         flag2 = true;
                         str2 = configKey;
                         updates2 = sectionUpdatesForGroup;
                     }
                 }
             }
             else
             {
                 update2 = declarationUpdates.GetDeclarationUpdate(configKey);
             }
             bool flag3 = (sectionGroupUpdate != null) && (sectionGroupUpdate.UpdatedXml != null);
             if (flag2)
             {
                 object o = utilWriter.CreateStreamCheckpoint();
                 string s = null;
                 if (flag3)
                 {
                     utilWriter.Write(sectionGroupUpdate.UpdatedXml);
                     reader.Read();
                 }
                 else
                 {
                     s = xmlUtil.UpdateStartElement(utilWriter, null, true, trueLinePosition, oldIndent);
                 }
                 if (s == null)
                 {
                     xmlUtil.CopyReaderToNextElement(utilWriter, true);
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:MgmtConfigurationRecord.cs

示例12: CopyConfig

 private void CopyConfig(SectionUpdates declarationUpdates, ConfigDefinitionUpdates definitionUpdates, byte[] buffer, string filename, NamespaceChange namespaceChange, XmlUtilWriter utilWriter)
 {
     this.CheckPreamble(base.ConfigStreamInfo.StreamEncoding.GetPreamble(), utilWriter, buffer);
     using (Stream stream = new MemoryStream(buffer))
     {
         using (XmlUtil util = new XmlUtil(stream, filename, false))
         {
             string str;
             XmlTextReader reader = util.Reader;
             reader.WhitespaceHandling = WhitespaceHandling.All;
             reader.Read();
             util.CopyReaderToNextElement(utilWriter, false);
             int indent = 4;
             int trueLinePosition = util.TrueLinePosition;
             bool isEmptyElement = reader.IsEmptyElement;
             if (namespaceChange == NamespaceChange.Add)
             {
                 str = string.Format(CultureInfo.InvariantCulture, "<configuration xmlns=\"{0}\">\r\n", new object[] { "http://schemas.microsoft.com/.NetConfiguration/v2.0" });
             }
             else if (namespaceChange == NamespaceChange.Remove)
             {
                 str = "<configuration>\r\n";
             }
             else
             {
                 str = null;
             }
             bool needsChildren = (declarationUpdates != null) || (definitionUpdates != null);
             string s = util.UpdateStartElement(utilWriter, str, needsChildren, trueLinePosition, indent);
             bool flag3 = false;
             if (!isEmptyElement)
             {
                 util.CopyReaderToNextElement(utilWriter, true);
                 indent = this.UpdateIndent(indent, util, utilWriter, trueLinePosition);
                 if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "configSections"))
                 {
                     flag3 = true;
                     int linePosition = util.TrueLinePosition;
                     bool flag4 = reader.IsEmptyElement;
                     if (declarationUpdates == null)
                     {
                         util.CopyOuterXmlToNextElement(utilWriter, true);
                     }
                     else
                     {
                         string str3 = util.UpdateStartElement(utilWriter, null, true, linePosition, indent);
                         if (!flag4)
                         {
                             util.CopyReaderToNextElement(utilWriter, true);
                             this.CopyConfigDeclarationsRecursive(declarationUpdates, util, utilWriter, string.Empty, linePosition, indent);
                         }
                         if (declarationUpdates.HasUnretrievedSections())
                         {
                             int num4 = 0;
                             if (str3 == null)
                             {
                                 num4 = util.TrueLinePosition;
                             }
                             if (!utilWriter.IsLastLineBlank)
                             {
                                 utilWriter.AppendNewLine();
                             }
                             this.WriteUnwrittenConfigDeclarations(declarationUpdates, utilWriter, linePosition + indent, indent, false);
                             if (str3 == null)
                             {
                                 utilWriter.AppendSpacesToLinePosition(num4);
                             }
                         }
                         if (str3 == null)
                         {
                             util.CopyXmlNode(utilWriter);
                         }
                         else
                         {
                             utilWriter.Write(str3);
                         }
                         util.CopyReaderToNextElement(utilWriter, true);
                     }
                 }
             }
             if (!flag3 && (declarationUpdates != null))
             {
                 int num5;
                 bool skipFirstIndent = (reader.Depth > 0) && (reader.NodeType == XmlNodeType.Element);
                 if (skipFirstIndent)
                 {
                     num5 = util.TrueLinePosition;
                 }
                 else
                 {
                     num5 = trueLinePosition + indent;
                 }
                 this.WriteNewConfigDeclarations(declarationUpdates, utilWriter, num5, indent, skipFirstIndent);
             }
             if (definitionUpdates != null)
             {
                 bool locationPathApplies = false;
                 LocationUpdates locationUpdates = null;
                 SectionUpdates sectionUpdates = null;
                 if (!base.IsLocationConfig)
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:MgmtConfigurationRecord.cs

示例13: WriteUnwrittenConfigDeclarationsRecursive

 private void WriteUnwrittenConfigDeclarationsRecursive(SectionUpdates declarationUpdates, XmlUtilWriter utilWriter, int linePosition, int indent, bool skipFirstIndent)
 {
     string[] unretrievedSectionNames = declarationUpdates.GetUnretrievedSectionNames();
     if (unretrievedSectionNames != null)
     {
         foreach (string str in unretrievedSectionNames)
         {
             if (!skipFirstIndent)
             {
                 utilWriter.AppendSpacesToLinePosition(linePosition);
             }
             skipFirstIndent = false;
             DeclarationUpdate declarationUpdate = declarationUpdates.GetDeclarationUpdate(str);
             if ((declarationUpdate != null) && !string.IsNullOrEmpty(declarationUpdate.UpdatedXml))
             {
                 utilWriter.Write(declarationUpdate.UpdatedXml);
                 utilWriter.AppendNewLine();
             }
         }
     }
     string[] unretrievedGroupNames = declarationUpdates.GetUnretrievedGroupNames();
     if (unretrievedGroupNames != null)
     {
         foreach (string str2 in unretrievedGroupNames)
         {
             if (base.TargetFramework != null)
             {
                 ConfigurationSectionGroup sectionGroup = this.GetSectionGroup(str2);
                 if ((sectionGroup != null) && !sectionGroup.ShouldSerializeSectionGroupInTargetVersion(base.TargetFramework))
                 {
                     declarationUpdates.MarkGroupAsRetrieved(str2);
                     continue;
                 }
             }
             if (!skipFirstIndent)
             {
                 utilWriter.AppendSpacesToLinePosition(linePosition);
             }
             skipFirstIndent = false;
             SectionUpdates sectionUpdatesForGroup = declarationUpdates.GetSectionUpdatesForGroup(str2);
             DeclarationUpdate sectionGroupUpdate = sectionUpdatesForGroup.GetSectionGroupUpdate();
             if (sectionGroupUpdate == null)
             {
                 utilWriter.Write("<sectionGroup name=\"" + str2 + "\">");
             }
             else
             {
                 utilWriter.Write(sectionGroupUpdate.UpdatedXml);
             }
             utilWriter.AppendNewLine();
             this.WriteUnwrittenConfigDeclarationsRecursive(sectionUpdatesForGroup, utilWriter, linePosition + indent, indent, false);
             utilWriter.AppendSpacesToLinePosition(linePosition);
             utilWriter.Write("</sectionGroup>\r\n");
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:56,代码来源:MgmtConfigurationRecord.cs

示例14: WriteNewConfigDefinitionsRecursive

 private bool WriteNewConfigDefinitionsRecursive(XmlUtilWriter utilWriter, SectionUpdates sectionUpdates, int linePosition, int indent, bool skipFirstIndent)
 {
     bool flag = false;
     string[] movedSectionNames = sectionUpdates.GetMovedSectionNames();
     if (movedSectionNames != null)
     {
         flag = true;
         foreach (string str in movedSectionNames)
         {
             DefinitionUpdate definitionUpdate = sectionUpdates.GetDefinitionUpdate(str);
             this.WriteSectionUpdate(utilWriter, definitionUpdate, linePosition, indent, skipFirstIndent);
             utilWriter.AppendNewLine();
             skipFirstIndent = false;
         }
     }
     string[] newGroupNames = sectionUpdates.GetNewGroupNames();
     if (newGroupNames != null)
     {
         foreach (string str2 in newGroupNames)
         {
             if (base.TargetFramework != null)
             {
                 ConfigurationSectionGroup sectionGroup = this.GetSectionGroup(str2);
                 if ((sectionGroup != null) && !sectionGroup.ShouldSerializeSectionGroupInTargetVersion(base.TargetFramework))
                 {
                     sectionUpdates.MarkGroupAsRetrieved(str2);
                     continue;
                 }
             }
             if (!skipFirstIndent)
             {
                 utilWriter.AppendSpacesToLinePosition(linePosition);
             }
             skipFirstIndent = false;
             utilWriter.Write("<" + str2 + ">\r\n");
             if (this.WriteNewConfigDefinitionsRecursive(utilWriter, sectionUpdates.GetSectionUpdatesForGroup(str2), linePosition + indent, indent, false))
             {
                 flag = true;
             }
             utilWriter.AppendSpacesToLinePosition(linePosition);
             utilWriter.Write("</" + str2 + ">\r\n");
         }
     }
     sectionUpdates.IsNew = false;
     return flag;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:MgmtConfigurationRecord.cs

示例15: WriteNewConfigDefinitions

 private void WriteNewConfigDefinitions(ConfigDefinitionUpdates configDefinitionUpdates, XmlUtilWriter utilWriter, int linePosition, int indent)
 {
     if (configDefinitionUpdates != null)
     {
         foreach (LocationUpdates updates in configDefinitionUpdates.LocationUpdatesList)
         {
             SectionUpdates sectionUpdates = updates.SectionUpdates;
             if (!sectionUpdates.IsEmpty && sectionUpdates.IsNew)
             {
                 configDefinitionUpdates.FlagLocationWritten();
                 bool flag = (base._locationSubPath != null) || !updates.IsDefault;
                 int num = linePosition;
                 utilWriter.AppendSpacesToLinePosition(linePosition);
                 if (flag)
                 {
                     if (base._locationSubPath == null)
                     {
                         utilWriter.Write(string.Format(CultureInfo.InvariantCulture, "<location {0} inheritInChildApplications=\"{1}\">\r\n", new object[] { updates.OverrideMode.LocationTagXmlString, BoolToString(updates.InheritInChildApps) }));
                     }
                     else
                     {
                         utilWriter.Write(string.Format(CultureInfo.InvariantCulture, "<location path=\"{2}\" {0} inheritInChildApplications=\"{1}\">\r\n", new object[] { updates.OverrideMode.LocationTagXmlString, BoolToString(updates.InheritInChildApps), base._locationSubPath }));
                     }
                     num += indent;
                     utilWriter.AppendSpacesToLinePosition(num);
                 }
                 this.WriteNewConfigDefinitionsRecursive(utilWriter, updates.SectionUpdates, num, indent, true);
                 if (flag)
                 {
                     utilWriter.AppendSpacesToLinePosition(linePosition);
                     utilWriter.Write("</location>");
                     utilWriter.AppendNewLine();
                 }
             }
         }
         if (configDefinitionUpdates.RequireLocation)
         {
             configDefinitionUpdates.FlagLocationWritten();
             utilWriter.AppendSpacesToLinePosition(linePosition);
             utilWriter.Write(string.Format(CultureInfo.InvariantCulture, "<location path=\"{2}\" {0} inheritInChildApplications=\"{1}\">\r\n", new object[] { OverrideModeSetting.LocationDefault.LocationTagXmlString, "true", base._locationSubPath }));
             utilWriter.AppendSpacesToLinePosition(linePosition);
             utilWriter.Write("</location>");
             utilWriter.AppendNewLine();
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:MgmtConfigurationRecord.cs


注:本文中的System.Configuration.XmlUtilWriter.AppendSpacesToLinePosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。