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


C# BinaryWriter.WriteLine方法代碼示例

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


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

示例1: WriteLine

 public static void WriteLine(this Stream stream, string line)
 {
     var writer = new BinaryWriter(stream, Encoding.UTF8, true);
     writer.WriteLine(line);
 }
開發者ID:ssardari,項目名稱:buskerproxy,代碼行數:5,代碼來源:Extension.cs

示例2: CopyHttpStream

        private static bool CopyHttpStream(Stream fromStream, Stream toStream, string firstLine = "", string sslTunnelDomain="")
        {
            bool keepAlive = false; 
            var encoding = Encoding.UTF8;
            string method;
            string version;
            string url;

            using (var fromStreamReader = new BinaryReader(fromStream, encoding, true))
            using (var toStreamWriter = new BinaryWriter(toStream, encoding, true))
            {
                if (String.IsNullOrEmpty(firstLine))
                    firstLine = fromStream.ReadLine();

                if (!String.IsNullOrEmpty(sslTunnelDomain))
                {
                    //modify the path in the http request to include the domain
                    ParseHttpCommand(firstLine, out method, out url, out version);
                    //modify the forward address so it has complete URL 
                    firstLine = method + ' ' + "https://" + sslTunnelDomain + url + ' ' + version;
                    firstLine += "\r\n";
                    firstLine += "X-Forward-Secure: true";
                }
                LogMessage(string.Format(firstLine));
                toStream.WriteLine(firstLine);
                toStream.Flush();

                string line;
                int contentLength = 0;
                bool chunked = false;

                //copy the headers
                while (!String.IsNullOrEmpty(line = fromStreamReader.ReadLine()))
                {
                    if (line.StartsWith("Content-Length:", true, CultureInfo.CurrentCulture))
                        contentLength = int.Parse(line.Replace("Content-Length:", ""));
                    if (line.StartsWith("Transfer-Encoding: chunked", true, CultureInfo.CurrentCulture))
                        chunked = true;
                    if (line.StartsWith("Proxy-Connection: Keep-Alive", true, CultureInfo.CurrentCulture))
                        keepAlive = true;
                    toStreamWriter.WriteLine(line);
                }
                toStreamWriter.WriteLine();
                if (contentLength > 0)
                    toStreamWriter.Write(fromStreamReader.ReadBytes(contentLength));

                if(chunked)
                {
                    while (!String.IsNullOrEmpty(line = fromStreamReader.ReadLine()))
                    {
                        contentLength = int.Parse(line, System.Globalization.NumberStyles.HexNumber);
                        toStreamWriter.Write(fromStreamReader.ReadBytes(contentLength));
                        fromStreamReader.ReadLine();
                    }
                }
                toStreamWriter.Flush();
            }
            return keepAlive;
        }
開發者ID:ssardari,項目名稱:buskerproxy,代碼行數:59,代碼來源:Listener.cs

示例3: Save

 public virtual void Save(string basename)
 {
     using (var output = new BinaryWriter(File.Create(basename))) {
         this.InputTokenizer.Save(output);
     }
     using (var output = File.CreateText(basename + ".names")) {
         foreach (var filename in this.FileNames) {
             output.WriteLine (filename);
         }
     }
     using (var output = new BinaryWriter(File.Create(basename + ".seq"))) {
         GenericIO<Sequence>.Save (output, this.Seq);
     }
     using (var output = new BinaryWriter(File.Create(basename + ".voc"))) {
         output.Write ((int)this.Voc.Count);
         foreach (var w in this.Voc) {
             output.Write (w);
         }
     }
 }
開發者ID:KeithNel,項目名稱:natix,代碼行數:20,代碼來源:SeqTextIR.cs

示例4: GetSslTunnelStream

        private static Stream GetSslTunnelStream(Stream stream, string version = "HTTP/1.1")
        {
            SslStream sslStream = null;
            //Browser wants to create a secure tunnel
            //read and ignore headers
            while (!String.IsNullOrEmpty(stream.ReadLine())) ;
            //tell the client that a tunnel has been established              
            LogMessage(string.Format("Doing CONNECT"));
            var connectStreamWriter = new BinaryWriter(stream);
            connectStreamWriter.WriteLine(version + " 200 Connection established");
            connectStreamWriter.WriteLine(String.Format("Timestamp: {0}", DateTime.Now.ToString()));
            connectStreamWriter.WriteLine("Proxy-agent: buskerproxy");
            connectStreamWriter.WriteLine();
            connectStreamWriter.Flush();

            //open a decrypting stream    
            sslStream = new SslStream(stream, false);
            try
            {
                sslStream.AuthenticateAsServer(_certificate, false, SslProtocols.Tls | SslProtocols.Ssl3 | SslProtocols.Ssl2, true);
            }
            catch (Exception ex)
            {
                stream.Close();
                sslStream.Close();
                return null;
            }
            return sslStream;
        }
開發者ID:ssardari,項目名稱:buskerproxy,代碼行數:29,代碼來源:Listener.cs


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