當前位置: 首頁>>代碼示例>>C#>>正文


C# SgmlReader.GetEncoding方法代碼示例

本文整理匯總了C#中Sgml.SgmlReader.GetEncoding方法的典型用法代碼示例。如果您正苦於以下問題:C# SgmlReader.GetEncoding方法的具體用法?C# SgmlReader.GetEncoding怎麽用?C# SgmlReader.GetEncoding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sgml.SgmlReader的用法示例。


在下文中一共展示了SgmlReader.GetEncoding方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Process

        void Process(SgmlReader reader, string uri)
        {
            if (uri == null) {
                reader.InputStream = Console.In;
            } else {
                reader.Href = uri;
            }

            if (this.encoding == null) {
                this.encoding = reader.GetEncoding();
            }

            XmlTextWriter w = null;
            if (output != null) {
                w = new XmlTextWriter(output, this.encoding);
            }
            else {
                w = new XmlTextWriter(Console.Out);
            }
            if (formatted) w.Formatting = Formatting.Indented;
            if (!noxmldecl) {
                w.WriteStartDocument();
            }
            reader.Read();
            while (!reader.EOF) {
                w.WriteNode(reader, true);
            }
            w.Flush();
            w.Close();
        }
開發者ID:panuganti,項目名稱:nreadability,代碼行數:30,代碼來源:Main.cs

示例2: Process

        void Process(SgmlReader reader, string uri, bool loadAsStream)
        {
            if (uri == null) {
                reader.InputStream = Console.In;
            }
            else if (loadAsStream) {
                Uri location = new Uri(uri);
                if (location.IsFile) {
                    reader.InputStream = new StreamReader(uri);
                } else {
                    WebRequest wr = WebRequest.Create(location);
                    reader.InputStream = new StreamReader(wr.GetResponse().GetResponseStream());
                }
            } else {
                reader.Href = uri;
            }

            if (debug) {
                Debug(reader);
                reader.Close();
                return;
            }
            if (crawl) {
                StartCrawl(reader, uri, basify);
                return;
            }

            if (this.encoding == null) {
                this.encoding = reader.GetEncoding();
            }

            XmlTextWriter w = null;
            if (output != null) {
                w = new XmlTextWriter(output, this.encoding);
            }
            else {
                w = new XmlTextWriter(Console.Out);
            }
            if (formatted) w.Formatting = Formatting.Indented;
            if (!noxmldecl) {
                w.WriteStartDocument();
            }
            if (testdoc) {
                XmlDocument doc = new XmlDocument();
                try {
                    doc.Load(reader);
                    doc.WriteTo(w);
                } catch (XmlException e) {
                    Console.WriteLine("Error:" + e.Message);
                    Console.WriteLine("at line " + e.LineNumber + " column " + e.LinePosition);
                }
            } else {
                reader.Read();
                while (!reader.EOF) {
                    w.WriteNode(reader, true);
                }
            }
            w.Flush();
            w.Close();
        }
開發者ID:panuganti,項目名稱:nreadability,代碼行數:60,代碼來源:Test.cs


注:本文中的Sgml.SgmlReader.GetEncoding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。