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


C# XmlReader.Dispose方法代码示例

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


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

示例1: ParsePartialContent

        internal XmlNamespaceManager ParsePartialContent(XmlNode parentNode, string innerxmltext, XmlNodeType nt)
        {
            //the function shouldn't be used to set innerxml for XmlDocument node
            Debug.Assert(parentNode.NodeType != XmlNodeType.Document);
            _doc = parentNode.OwnerDocument;
            Debug.Assert(_doc != null);
            XmlParserContext pc = GetContext(parentNode);
            _reader = CreateInnerXmlReader(innerxmltext, nt, pc, _doc);
            try
            {
                _preserveWhitespace = true;
                bool bOrigLoading = _doc.IsLoading;
                _doc.IsLoading = true;

                if (nt == XmlNodeType.Entity)
                {
                    XmlNode node = null;
                    while (_reader.Read() && (node = LoadNodeDirect()) != null)
                    {
                        parentNode.AppendChildForLoad(node, _doc);
                    }
                }
                else
                {
                    XmlNode node = null;
                    while (_reader.Read() && (node = LoadNode(true)) != null)
                    {
                        parentNode.AppendChildForLoad(node, _doc);
                    }
                }
                _doc.IsLoading = bOrigLoading;
            }
            finally
            {
                _reader.Dispose();
            }
            return pc.NamespaceManager;
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:38,代码来源:XmlLoader.cs

示例2: NestRead

 private XmlReader NestRead(XmlReader r)
 {
     r.Read();
     r.Read();
     if (!(r.Name == "elem0" && r.NodeType == XmlNodeType.Element))
     {
         NestRead(r.ReadSubtree());
     }
     r.Dispose();
     return r;
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:11,代码来源:ReadSubTree.cs

示例3: TransformResolver

        public int TransformResolver(String szXmlFile, XmlResolver xr, bool errorCase)
        {
            lock (s_outFileMemoryLock)
            {
                szXmlFile = FullFilePath(szXmlFile);

                _output.WriteLine("Loading XML {0}", szXmlFile);
                IXPathNavigable xd = LoadXML(szXmlFile, _docType);

                _output.WriteLine("Executing transform");
                xrXSLT = null;
                Stream strmTemp = null;

                switch (_nTransform)
                {
                    case TransformType.Reader:
                        xrXSLT = xslt.Transform(xd, null, xr);
                        if (errorCase)
                        {
                            try
                            {
                                while (xrXSLT.Read()) { }
                            }
                            catch (Exception ex)
                            {
                                throw (ex);
                            }
                            finally
                            {
                                if (xrXSLT != null)
                                    xrXSLT.Dispose();
                            }
                        }
                        break;

                    case TransformType.Stream:
                        try
                        {
                            strmTemp = new FileStream(_strOutFile, FileMode.Create, FileAccess.ReadWrite);
                            xslt.Transform(xd, null, strmTemp, xr);
                        }
                        catch (Exception ex)
                        {
                            throw (ex);
                        }
                        finally
                        {
                            if (strmTemp != null)
                                strmTemp.Dispose();
                        }
                        break;

                    case TransformType.Writer:
                        XmlWriter xw = null;
                        try
                        {
                            xw = new XmlTextWriter(_strOutFile, Encoding.UTF8);
                            xw.WriteStartDocument();
                            xslt.Transform(xd, null, xw, xr);
                        }
                        catch (Exception ex)
                        {
                            throw (ex);
                        }
                        finally
                        {
                            if (xw != null)
                                xw.Dispose();
                        }
                        break;

                    case TransformType.TextWriter:
                        TextWriter tw = null;
                        try
                        {
                            tw = new StreamWriter(new FileStream(_strOutFile, FileMode.Create, FileAccess.Write), Encoding.UTF8);
                            xslt.Transform(xd, null, tw, xr);
                        }
                        catch (Exception ex)
                        {
                            throw (ex);
                        }
                        finally
                        {
                            if (tw != null)
                                tw.Dispose();
                        }
                        break;
                }
                return 1;
            }
        }
开发者ID:shmao,项目名称:corefx,代码行数:92,代码来源:XSLTransform.cs

示例4: Load

        public void Load(string _strXslFile, string _strXmlFile)
        {
            _xrData = XmlReader.Create(_strPath + _strXmlFile);
            _xd = new XPathDocument(_xrData, XmlSpace.Preserve);
            _xrData.Dispose();

            XmlReaderSettings xrs = new XmlReaderSettings();
#pragma warning disable 0618
            xrs.ProhibitDtd = false;
#pragma warning restore 0618
            XmlReader xrTemp = XmlReader.Create(_strPath + _strXslFile, xrs);
            xsltSameInstance.Load(xrTemp);
        }
开发者ID:chcosta,项目名称:corefx,代码行数:13,代码来源:XslTransformMultith.cs

示例5: LoadFromConfigXmlReader

        private void LoadFromConfigXmlReader(ConfigXmlReader reader)
        {
            IConfigErrorInfo err = (IConfigErrorInfo) reader;
            _filename = err.Filename;
            _lineOffset = err.LineNumber + 1;

            try {
                _reader = reader;
                base.Load(_reader);
            }
            finally {
                if (_reader != null) {
                    _reader.Dispose();
                    _reader = null;
                }
            }
        }
开发者ID:kichalla,项目名称:systemconfigurationport,代码行数:17,代码来源:ErrorInfoXmlDocument.cs

示例6: Load

 public void Load(string filename)
 {
     _filename = filename;
     try {
         _reader = XmlReader.Create(filename);
         //_reader.XmlResolver = null;
         base.Load(_reader);
     }
     finally {
         if (_reader != null) {
             _reader.Dispose();
             _reader = null;
         }
     }
 }
开发者ID:kichalla,项目名称:systemconfigurationport,代码行数:15,代码来源:ErrorInfoXmlDocument.cs

示例7: CompareReader

        public bool CompareReader(XmlReader xrExpected, XmlDiffOption option)
        {
            bool bReturn = false;

            XmlReader xrActual = GetReader();

            XmlDiff diff = new XmlDiff();
            diff.Option = option;

            try
            {
                bReturn = diff.Compare(xrExpected, xrActual);
            }
            catch (Exception e)
            {
                CError.WriteLine(e);
            }
            finally
            {
                xrActual.Dispose();
                xrExpected.Dispose();
            }
            if (!bReturn)
            {
                CError.WriteLine("Mismatch in XmlDiff");
                CError.WriteLine("Actual o/p:");
                CError.WriteLine(this.GetString());
            }

            return bReturn;
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:31,代码来源:WriterFactory.cs

示例8: destroyXmlReader

 private void destroyXmlReader(XmlReader xmlreader)
 {
     if (xmlreader != null)
     { xmlreader.Close(); xmlreader.Dispose(); }
 }
开发者ID:WilliamGDavis,项目名称:GW2_Account_Selector,代码行数:5,代码来源:Form1.cs


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