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


C# StringWriter.Write方法代码示例

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


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

示例1: WriteStartLine

    /// <summary>
    /// Write Start Line.
    /// </summary>
    /// <param name="request">Http Request.</param>
    /// <param name="writer">String Writer.</param>
    private static void WriteStartLine(HttpRequest request, StringWriter writer)
    {
        const string SPACE = " ";

            writer.Write(request.HttpMethod);
            writer.Write(SPACE + request.Url);
            writer.WriteLine(SPACE + request.ServerVariables["SERVER_PROTOCOL"]);
    }
开发者ID:RuhuiCheng,项目名称:Talent,代码行数:13,代码来源:RawHttpRequest.cs

示例2: ToString

 public override string ToString()
 {
     StringWriter buf = new StringWriter();
     buf.Write("[ ");
     foreach (object o in val) {
         buf.Write(String.Format("{0} ", PrettyPrinter.Reformat(o)));
     }
     buf.Write(']');
     return buf.ToString();
 }
开发者ID:foogoof,项目名称:nihilisp,代码行数:10,代码来源:NLVector.cs

示例3: ToString

 public override string ToString()
 {
     StringWriter buf = new StringWriter();
     buf.Write("{ ");
     foreach (var pair in _val) {
         buf.Write(String.Format("{0} {1} ", PrettyPrinter.Reformat(pair.Key), PrettyPrinter.Reformat(pair.Value)));
     }
     buf.Write('}');
     return buf.ToString();
 }
开发者ID:foogoof,项目名称:nihilisp,代码行数:10,代码来源:NLMap.cs

示例4: runTest

	public bool runTest()
	{
		int iCountErrors = 0;
		int iCountTestcases = 0;
        Char[] cArr = new Char[5] ; ;
        StringBuilder sb = new StringBuilder(40);
        StringWriter sw = new StringWriter(sb);
        StringReader sr;
        iCountTestcases++;
        bool[] bArr = new bool[]{  true,true,true,true,true,false,false,false,false,false};
		try {
			for(int i = 0 ; i < bArr.Length ; i++)
				sw.Write(bArr[i]);
			sr = new StringReader(sw.GetStringBuilder().ToString());
			for(int i = 0 ; i < bArr.Length ; i++) {
                sr.Read(cArr, 0, bArr[i].ToString().Length);
				if(new String(cArr, 0, bArr[i].ToString().Length) != bArr[i].ToString()) {
					iCountErrors++;
					printerr( "Error_298vc_"+i+"! Expected=="+bArr[i].ToString()+", got=="+new String(cArr));
				}
			}
		} catch (Exception exc) {
			iCountErrors++;
			printerr( "Error_298yg! Unexpected exception thrown, exc=="+exc.ToString());
		}
        iCountTestcases++;
        bArr = new bool[10000];
        for(int i = 0 ; i < bArr.Length ; i++)
            bArr[i] = Convert.ToBoolean(rand.Next(0,2));
		try {
            sb.Length = 0;
			for(int i = 0 ; i < bArr.Length ; i++)
				sw.Write(bArr[i]);
			sr = new StringReader(sw.GetStringBuilder().ToString());
			for(int i = 0 ; i < bArr.Length ; i++) {
                sr.Read(cArr, 0, bArr[i].ToString().Length);
				if(new String(cArr, 0, bArr[i].ToString().Length) != bArr[i].ToString()) {
					iCountErrors++;
					printerr( "Error_5754_"+i+"! Expected=="+bArr[i].ToString()+", got=="+new String(cArr));
				}
			}
		} catch (Exception exc) {
			iCountErrors++;
			printerr( "Error_0845! Unexpected exception thrown, exc=="+exc.ToString());
		}
        if ( iCountErrors == 0 ) {
			Console.WriteLine( "paSs. iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}else {
			Console.WriteLine("FAiL! iCountErrors=="+iCountErrors.ToString() );
			return false;
		}
	}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:53,代码来源:co9401write_bool.cs

示例5: ToString

	public override string ToString(){
		StringWriter sw = new StringWriter();
		foreach(Vector3 n in locations){
			sw.Write(n.ToString());
		}
		return sw.ToString();
	}
开发者ID:JBillingsley,项目名称:eecs-390-rts,代码行数:7,代码来源:Route.cs

示例6: runTest

	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strValue = String.Empty;
		try {
			StringBuilder sb = new StringBuilder(40);
			StringWriter sw = new StringWriter(sb);
			sw.Write(4);
			sb = sw.GetStringBuilder();
			iCountTestcases++;
			if(!sb.ToString().Equals("4")) {
				iCountErrors++;
				printerr( "Error_298vc! Unexpected value written, sb=="+sb.ToString());
			}
		} catch (Exception exc) {
			iCountErrors++;
			printerr( "Error_298yg! Unexpected exception thrown, exc=="+exc.ToString());
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:31,代码来源:co5556ctor_sb.cs

示例7: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        string strTempDirPath = string.Empty;

        // Create the Image converter. Optionally you can specify the virtual browser
        // width as parameter. 1024 pixels is default, 0 means autodetect
        ExpertPdf.HtmlToPdf.ImgConverter imgConverter = new ExpertPdf.HtmlToPdf.ImgConverter();

        if (ConfigurationManager.AppSettings.AllKeys.Contains("UserName") && ConfigurationManager.AppSettings.AllKeys.Contains("Password"))
        {
            //use the Account details which has fuill access on the site(all folders)
            string Username = ConfigurationManager.AppSettings["Domain"].ToString() + "\\" + ConfigurationManager.AppSettings["UserName"].ToString();
            string Password = ConfigurationManager.AppSettings["Password"].ToString();

            //add the authentication options to PDF Converter
            imgConverter.AuthenticationUsername = Username;
            imgConverter.AuthenticationPassword = Password;
        }

        // set the license key
        imgConverter.LicenseKey = ConfigurationManager.AppSettings["pdfLicence"]; ;
        // Performs the conversion and get the image bytes that you can further
        // save to a file or send as a browser response
        // imgConverter.PageWidth = Convert.ToInt32(Request.Params["Width"]);

        imgConverter.PageWidth = 1000;
        //imgConverter.PageHeight=800
        //Read the HTML from its location path
        strHtmlfilePath = Session["htmlpagepath"].ToString();

        if (strHtmlfilePath != null)
            sr = new StreamReader(strHtmlfilePath);

        sb = new StringBuilder();
        sw = new StringWriter(sb);
        sw.Write(sr.ReadToEnd());

        imgConverter.ConversionDelay = 2;
        byte[] imgBytes = imgConverter.GetImageBytesFromHtmlString(sb.ToString(), System.Drawing.Imaging.ImageFormat.Jpeg);
        // send the image as a response to the browser for download

        string fileName = RandomString();
        fileName = "Print" + "_" + fileName + ".jpeg";

        //Get the Location path  excluding html file name
        strTempDirPath = strHtmlfilePath.Substring(0, strHtmlfilePath.LastIndexOf('/'));

        //Added by Rajesh for Mais Expert CR - Start
        if (!Directory.Exists((strTempDirPath)))
            Directory.CreateDirectory(strTempDirPath);
        //Added by Rajesh for Mais Expert CR - End
        File.WriteAllBytes((strTempDirPath +"\\" + fileName), imgBytes);

        //Set the Relative Path : Temp\mailpdf
        imgPrint.Src = "~/" + ConfigurationManager.AppSettings["tempfolder"] + "/" + Constants.EMAILPDFFOLDER + "/" + fileName;

        btnClose.Attributes.Add("onclick", "javascript:fnCloseWindow();");

        btnPrint.Attributes.Add("onclick", "javascript:fnPrintWindow();");
    }
开发者ID:shanghaiese,项目名称:argicast,代码行数:60,代码来源:Print.aspx.cs

示例8: RespCallback

    private static void RespCallback(IAsyncResult ar)
    {
        HttpWebRequest req;
        HttpWebResponse resp;
        int BytesRead;
        StreamReader Reader;
        StringWriter Writer;

        req=(HttpWebRequest)(Object)ar;
        resp=(HttpWebResponse)req.EndGetResponse(ar);

        BytesRead=0;
        char[] Buffer=new char[MAX];

        Reader=new StreamReader(resp.GetResponseStream(),System.Text.Encoding.UTF8);
        Writer=new StringWriter();

        BytesRead=Reader.Read(Buffer,0,MAX);
        while(BytesRead!=0)
        {
            Writer.Write(Buffer,0,MAX);
            BytesRead=Reader.Read(Buffer,0,MAX);
        }

        Console.WriteLine("Message="+Writer.ToString());
    }
开发者ID:ShiJess,项目名称:CompanyStudy,代码行数:26,代码来源:GetURLAsync.cs

示例9: runTest

	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strValue = String.Empty;
		Char[] chArr = new Char[]{
			Char.MinValue
			,Char.MaxValue
			,'\t'
			,' '
			,'$'
			,'@'
			,'#'
			,'\0'
			,'\v'
			,'\''
			,'\u3190'
			,'\uC3A0'
			,'A'
			,'5'
			,'\uFE70' 
			,'-'
			,';'
			,'\u00E6'
			,'\n'
			,'\v'
		};
		try {
			StringBuilder sb = new StringBuilder(40);
			StringWriter sw = new StringWriter(sb);
			StringReader sr;
			for(int i = 0 ; i < chArr.Length ; i++)
				sb.Append(chArr[i]);
			sw.Write(sb.ToString());
			sr = new StringReader(sw.GetStringBuilder().ToString());
			Int32 tmp = 0;
			for(int i = 0 ; i < chArr.Length ; i++) {
				iCountTestcases++;
				if((tmp = sr.Read()) != (Int32)chArr[i]) {
					iCountErrors++;
					printerr( "Error_298vc_"+i+"! Expected=="+(Int32)chArr[i]+", got=="+tmp);
				}
			}
		} catch (Exception exc) {
			iCountErrors++;
			printerr( "Error_298yg! Unexpected exception thrown, exc=="+exc.ToString());
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:59,代码来源:co5559write_str.cs

示例10: Response_Bug80944

	static byte[] Response_Bug80944 (Socket socket)
	{
		StringWriter sw = new StringWriter ();
		sw.WriteLine ("HTTP/1.1 200 OK");
		sw.WriteLine ("Content-Type: text/plain; charset=UTF-8");
		sw.WriteLine ("Content-Length: 4");
		sw.WriteLine ();
		sw.Write ("FINE");

		return Encoding.UTF8.GetBytes (sw.ToString ());
	}
开发者ID:mono,项目名称:gert,代码行数:11,代码来源:test.cs

示例11: Main

    static void Main()
    {
        string inputStr = "Hi!";
        StringWriter sw = new StringWriter();

        foreach (var ch in inputStr)
        {
            sw.Write("\\u{0:X4}", (int)ch);
        }
        Console.WriteLine(sw.ToString());
    }
开发者ID:plamenshipkovenski,项目名称:CSharpPart2,代码行数:11,代码来源:convertStringToSequenceOfUnicodeCharLiterals.cs

示例12: Main

    static void Main()
    {
        //string urlStr = "http://www.devbg.org/forum/index.php";
        Console.WriteLine("input url:");
        string urlStr = Console.ReadLine();
        StringWriter sw = new StringWriter();

        sw.WriteLine("[protocol] = {0}", GetProtocolPart(urlStr));
        sw.WriteLine("[server] = {0}", GetServerPart(urlStr));
        sw.Write("[resource] = {0}", GetResourcePart(urlStr));

        Console.WriteLine(sw.ToString());
    }
开发者ID:plamenshipkovenski,项目名称:CSharpPart2,代码行数:13,代码来源:extractProtocolServerResourceElementsFromURL.cs

示例13: Page_Load

  protected void Page_Load(object sender, EventArgs e)
  {
    // Disable cache
    Response.AddHeader("Pragma", "no-cache");
    Response.AddHeader("Cache-Control", "no-store");
    Response.AddHeader("Expires", "0");
    
    // ping
    ChatServer chatbox = Application["Chatbox"] as ChatServer;
    Ping ping = chatbox.Ping(Context);

    StringWriter writer = new StringWriter();
    writer.WriteLine("id:{0},", ping.MyUser.Id);
    writer.WriteLine("events:[");
    for (int i=0; i<ping.Events.Count; i++)
    {
      Event evt = ping.Events[i];
      writer.Write("[{0},\"{1}\",\"{2}\"]{3}", evt.User.Id, evt.Property.Name, evt.Property.Value, (i < ping.Events.Count - 1)? "," : "");
    }
    writer.WriteLine("]");
    Response.Write(writer.ToString());
  }
开发者ID:dineshkummarc,项目名称:q42multiplayer-v1.0.0,代码行数:22,代码来源:ping.aspx.cs

示例14: runTest

    public bool runTest()
	{
		Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strValue = String.Empty;
        Char[] chArr = new Char[]{
			Char.MinValue
			,Char.MaxValue
			,'\t'
			,' '
			,'$'
			,'@'
			,'#'
			,'\0'
			,'\v'
			,'\''
			,'\u3190'
			,'\uC3A0'
			,'A'
			,'5'
			,'\uFE70' 
			,'-'
			,';'
			,'\u00E6'
		};
		try {
			StringWriter sw = new StringWriter();
			iCountTestcases++;
			try {
				iCountTestcases++;
				sw.Write(null, 0, 0);
				iCountErrors++;
				printerr( "Error_5787s! Expected exception not thrown, sw=="+sw.ToString());
			} catch (ArgumentNullException) {
		    }
		} catch (Exception exc) {
			iCountErrors++;
			printerr( "ERror_91098! Unexpected exception thrown, exc=="+exc.ToString());
		}
        iCountTestcases++;
        for(int iLoop = 0 ; iLoop < iArrInvalidValues.Length ; iLoop++ ){
    		try {
    			StringWriter sw = new StringWriter();
    			try {
    				sw.Write(chArr, iArrInvalidValues[iLoop], 0);
    				iCountErrors++;
    				printerr( "Error_298vy! Expected exception not thrown, sw=="+sw.ToString());
    			} catch (ArgumentOutOfRangeException) {
    			} 
    		} catch (Exception exc) {
    			iCountErrors++;
    			printerr( "Error_98y89! Unexpected exception thrown, exc=="+exc.ToString());
    		} 
        }
        iCountTestcases++;
        for(int iLoop = 0 ; iLoop < iArrInvalidValues.Length ; iLoop++ ){
    		try {
    			StringWriter sw = new StringWriter();
    			try {
    				sw.Write(chArr, 0, iArrInvalidValues[iLoop]);
    				iCountErrors++;
    				printerr( "Error_209ux! Expected exception not thrown, sw=="+sw.ToString());
    			} catch (ArgumentOutOfRangeException) {
    			}
    		} catch (Exception exc) {
    			iCountErrors++;
    			printerr( "Error_298cy! Unexpected exception thrown, exc=="+exc.ToString());
    		}
        }
        iCountTestcases++;
        for(int iLoop = 0 ; iLoop < iArrLargeValues.Length ; iLoop++ ){
            try {
    			StringWriter sw = new StringWriter();
    			try {
    				sw.Write(chArr, iArrLargeValues[iLoop], chArr.Length);
    				iCountErrors++;
    				printerr( "Error_20deh! Expected exception not thrown, sw=="+sw.ToString());
    			} catch (ArgumentException) {
    			} 
    		} catch (Exception exc) {
    			iCountErrors++;
    			printerr( "Error_298gs! Unexpected exception thrown, exc=="+exc.ToString());
    		}
        }
        iCountTestcases++;
        for(int iLoop = 0 ; iLoop < iArrLargeValues.Length ; iLoop++ ){
            try {
    			StringWriter sw = new StringWriter();
    			try {
    				sw.Write(chArr, 1, iArrLargeValues[iLoop]);
    				iCountErrors++;
    				printerr( "Error_20deh! Expected exception not thrown, sw=="+sw.ToString());
    			} catch (ArgumentException) {
    			} 
    		} catch (Exception exc) {
    			iCountErrors++;
    			printerr( "Error_298gs! Unexpected exception thrown, exc=="+exc.ToString());
    		}
        }
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co5558write_charr_ii.cs

示例15: LogPacket

    // LogPacket: dump a packet to the console
    private static void LogPacket(Packet packet, IPEndPoint endPoint, Direction direction)
    {
        if (logGrep != null) {
            bool match = false;
            foreach (Block block in packet.Blocks())
                foreach (Field field in block.Fields) {
                    string value;
                    if (field.Layout.Type == FieldType.Variable)
                        value = DataConvert.toChoppedString(field.Data);
                    else
                        value = field.Data.ToString();
                    if (Regex.Match(packet.Layout.Name + "." + block.Layout.Name + "." + field.Layout.Name + " = " + value, logGrep, RegexOptions.IgnoreCase).Success) {
                        match = true;
                        break;
                    }

                    // try matching variable fields in 0x notation
                    if (field.Layout.Type == FieldType.Variable) {
                        StringWriter sw = new StringWriter();
                        sw.Write("0x");
                        foreach (byte b in (byte[])field.Data)
                            sw.Write("{0:x2}", b);
                        if (Regex.Match(packet.Layout.Name + "." + block.Layout.Name + "." + field.Layout.Name + " = " + sw, logGrep, RegexOptions.IgnoreCase).Success) {
                            match = true;
                            break;
                        }
                    }
                }
            if (!match)
                return;
        }

        Console.WriteLine("{0} {1,21} {2,5} {3}{4}{5}"
                 ,direction == Direction.Incoming ? "<--" : "-->"
                 ,endPoint
                 ,packet.Sequence
                 ,InterpretOptions(packet.Data[0])
                 ,Environment.NewLine
                 ,packet
                 );
    }
开发者ID:BackupTheBerlios,项目名称:libsecondlife-svn,代码行数:42,代码来源:Analyst.cs


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