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


C# TextWriter.Write方法代码示例

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


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

示例1: DoLog

 private static void DoLog(String logMessage, TextWriter w)
 {
     w.Write("{0}", DateTime.Now.ToString("MM/dd/yy HH:mm"));
     w.Write(" {0}", logMessage);
     w.Write("\r\n");
     w.Flush();
 }
开发者ID:mihle,项目名称:VaultService,代码行数:7,代码来源:Logger.cs

示例2: WriteToStream

 public static void WriteToStream(TextWriter stream, DataTable table, bool header, bool quoteall, char separator)
 {
     if (header)
     {
         for (int i = 0; i < table.Columns.Count; i++)
         {
             WriteItem(stream, table.Columns[i].Caption, quoteall, separator);
             if (i < table.Columns.Count - 1)
                 stream.Write(separator);
             else
                 stream.Write('\n');
         }
     }
     foreach (DataRow row in table.Rows)
     {
         for (int i = 0; i < table.Columns.Count; i++)
         {
             WriteItem(stream, row[i], quoteall, separator);
             if (i < table.Columns.Count - 1)
                 stream.Write(separator);
             else
                 stream.Write('\n');
         }
     }
 }
开发者ID:hafizor,项目名称:stgeorge,代码行数:25,代码来源:CsvWriter.cs

示例3: WriteItem

 private static void WriteItem(TextWriter stream, object item, bool quoteall, char separator)
 {
     if (item == null)
         return;
     string s = item.ToString();
     if (quoteall || s.IndexOfAny(new char[] { '"', '\x0A', '\x0D', separator }) > -1)
         stream.Write("\"" + s.Replace("\"", "\"\"") + "\"");
     else
         stream.Write(s);
 }
开发者ID:hafizor,项目名称:stgeorge,代码行数:10,代码来源:CsvWriter.cs

示例4: WriteCSVLine

 void WriteCSVLine(TextWriter file, IEnumerable items)
 {
     bool first=true;
     foreach (var item in items)
     {
         if (!first)
             file.Write(',');
         else
             first = false;
         file.Write('"');
         file.Write(item);
         file.Write('"');
     }
     file.Write("\r\n");
 }
开发者ID:BlurryRoots,项目名称:Craft,代码行数:15,代码来源:RandomizerTester.cs

示例5: Log

 private static void Log(Exception e, TextWriter w)
 {
     w.Write("\r\nLog Entry: ");
     w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString());
     w.WriteLine("{0} : {1}", e.Message , e.StackTrace);
     w.WriteLine("-------------------------------");
 }
开发者ID:sealuzh,项目名称:PersonalAnalytics,代码行数:7,代码来源:Logger.cs

示例6: Log

 public static void Log(string logMessage, TextWriter w)
 {
     w.Write("\r\nLog Entry : ");
     w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(),
         DateTime.Now.ToLongDateString());
     w.WriteLine("  :");
     w.WriteLine("  :{0}", logMessage);
     w.WriteLine("-------------------------------");
 }
开发者ID:kjeans,项目名称:online-shop,代码行数:9,代码来源:paypal.aspx.cs

示例7: DumpMethods

 public static void DumpMethods(TextWriter tw, TypeDefinition type)
 {
     foreach (MethodDefinition m in type.Methods)
     {
         tw.Write("{0} . {1}(", type.Name, m.Name);
         bool b = true;
         foreach (var p in m.Parameters)
         {
             if (!b)
             {
                 tw.Write(",");
             }
             b = false;
             tw.Write("{0}", p.ParameterType.FullName);
         }
         tw.WriteLine(")");
     }
 }
开发者ID:MeidoDev,项目名称:cm3d2-advanced-maid-settings,代码行数:18,代码来源:PatcherHelper.cs

示例8: Error

 public void Error(String ErrorMessage, bool writeinFile)
 {
     if (writeinFile == true)/*Write in a file located at C:\Users\Public\Documents\VisualBlock*/{
         TextWriter errorInFile = new TextWriter();
         errorInFile.Write(ErrorMessage, @"C:\Users\Public\Documents\VisualBlock\Error.txt");
         errorInFile.Close();
     }
     else{
         MessageBox.Show(ErrorMessage, "Error");
     }
 }
开发者ID:VisualBlockStudios,项目名称:vbsMinecraftServerHost,代码行数:11,代码来源:Core.cs

示例9: Main

 static void Main(string[] args)
 {
     var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     var workbookPath = Path.Combine(dir, "PLIB APIs.xlsx");
     var excelReader = new ExcelReader(workbookPath);
     var excelTable = excelReader.Read();
     var collection = (new ExcelAdapter()).Convert(excelTable);
     Console.WriteLine("Converting Excel to text file...");
     var writer = new TextWriter(Path.Combine(dir, "PLIB APIs.txt"));
     writer.Write(collection);
     Console.WriteLine("Conversion completed.");
 }
开发者ID:object,项目名称:PclAnalyzer,代码行数:12,代码来源:Program.cs

示例10: WriteLine

 private void WriteLine(TextWriter stream, String message, Object[] args, Boolean error = false)
 {
     if (String.IsNullOrEmpty(message)) {
         stream.WriteLine();
         return;
     }
     if (error) Console.ForegroundColor = ConsoleColor.Red;
     if (!String.IsNullOrEmpty(this.Prefix)) {
         if (!error) Console.ForegroundColor = ConsoleColor.Cyan;
         stream.Write(this.Prefix);
         stream.Write(' ');
         if (!error) Console.ResetColor();
     }
     if (this.PrintTimestamp) {
         stream.Write(DateTime.Now.ToString("HH:mm:ss.fff"));
         stream.Write(' ');
     }
     if ((null != args) && (0 < args.Length))
         message = String.Format(message, args);
     stream.WriteLine(message);
     if (error) Console.ResetColor();
 }
开发者ID:FirstWaveSoftware,项目名称:TsRecompiler,代码行数:22,代码来源:Logging.cs

示例11: FixupHtml

	private static void FixupHtml (string filename, int workfile_id, string md5, TextWriter writer)
	{
		string [] find;
		string [] replace;
		string line;
		string name = !string.IsNullOrEmpty (md5) ? "md5" : "workfile_id";
		string value = !string.IsNullOrEmpty (md5) ? md5 : workfile_id.ToString ();

		find = new string [] { 
				"img src=\"", 
				"img src='", 
				"a href=\"", 
				"a href='" };

		replace = new string []{
				string.Format ("img src=\"ViewHtmlReport.aspx?{1}={0}&amp;filename=", value, name),
				string.Format ("img src='ViewHtmlReport.aspx?{1}={0}&amp;filename=", value, name),
				string.Format ("a href=\"ViewHtmlReport.aspx?{1}={0}&amp;filename=", value, name),
				string.Format ("a href='ViewHtmlReport.aspx?{1}={0}&amp;filename=", value, name)};

		using (FileStream fs_reader = new FileStream (filename, FileMode.Open, FileAccess.Read, FileShare.Read)) {
			using (StreamReader reader = new StreamReader (fs_reader)) {
				while (null != (line = reader.ReadLine ())) {
					for (int i = 0; i < find.Length; i++)
						line = line.Replace (find [i], replace [i]);

					// undo any changes for relative links
					line = line.Replace (string.Format ("ViewHtmlReport.aspx?workfile_id={0}&amp;filename=#", workfile_id), "#");
					// undo any changes for javascript links
					line = line.Replace (string.Format ("ViewHtmlReport.aspx?workfile_id={0}&amp;filename=javascript", workfile_id), "javascript");
					// undo any changes for external links
					line = line.Replace (string.Format ("ViewHtmlReport.aspx?workfile_id={0}&amp;filename=http://", workfile_id), "http://");

					writer.Write (line);
					writer.Write ('\n');
				}
			}
		}
	}
开发者ID:rolfbjarne,项目名称:monkeywrench,代码行数:39,代码来源:ViewHtmlReport.aspx.cs

示例12: WriteLicenseStatement

    internal void WriteLicenseStatement(TextWriter/*!*/ writer) {
        writer.Write(
@"/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * [email protected] By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 *
 * ***************************************************************************/

");
    }
开发者ID:atczyc,项目名称:ironruby,代码行数:19,代码来源:Generator.cs

示例13: PrintCSC

            internal void PrintCSC(TextWriter textWriter, String indentation,
                                   String curNS, StringBuilder sb)
            {
                Util.Log("URTSimpleType.PrintCSC name "+Name+" curNS "+curNS);                              

                // Print only if the type is not an emittable field type
                if (IsEmittableFieldType == true)
                    return;

                if (bNestedType && !bNestedTypePrint)
                    return;

                // Handle encoding
                if (_encoding != null)
                {
                    // sb.Length = 0;
                    // sb.Append(indentation);
                }

                sb.Length = 0;
                sb.Append("\n"); 
                sb.Append(indentation);
                sb.Append("[");
                sb.Append("Serializable, ");
                sb.Append("SoapType(");

                if (_parser._xsdVersion == XsdVersion.V1999)
                {
                    sb.Append("SoapOptions=SoapOption.Option1|SoapOption.AlwaysIncludeTypes|SoapOption.XsdString|SoapOption.EmbedAll,");
                }
                else if (_parser._xsdVersion == XsdVersion.V2000)
                {
                    sb.Append("SoapOptions=SoapOption.Option2|SoapOption.AlwaysIncludeTypes|SoapOption.XsdString|SoapOption.EmbedAll,");
                }

                // Need namespace for clr type because proxy dll might have a different name than server dll
                sb.Append("XmlNamespace=");
                sb.Append(WsdlParser.IsValidUrl(UrlNS));
                sb.Append(", XmlTypeNamespace=");
                sb.Append(WsdlParser.IsValidUrl(UrlNS)); 

                sb.Append(")]");
                textWriter.WriteLine(sb);


                // Print type
                sb.Length = 0;
                sb.Append(indentation);

                // Handle Enum case
                if (IsEnum)
                    sb.Append("public enum ");
                else
                    sb.Append("public class ");

                if (_bNestedType)
                    sb.Append(WsdlParser.IsValidCS(NestedTypeName));
                else
                    sb.Append(WsdlParser.IsValidCS(Name));
                if (_baseType != null)
                {
                    sb.Append(" : ");
                    sb.Append(WsdlParser.IsValidCSAttr(_baseType.GetName(curNS)));
                }
                else if (IsEnum && _enumType != null && _enumType.Length > 0)
                {
                    sb.Append(" : ");
                    sb.Append(WsdlParser.IsValidCSAttr(_enumType));
                }

                textWriter.WriteLine(sb);

                textWriter.Write(indentation);
                textWriter.WriteLine('{');

                String newIndentation = indentation + "    ";
                for (int i=0;i<_facets.Count;i++)
                {
                    Util.Log("URTSimpleType.PrintCSC Invoke _facets PrintCSC ");                                                                                                        
                    ((SchemaFacet) _facets[i]).PrintCSC(textWriter, newIndentation, curNS, sb);
                }

                textWriter.Write(indentation);
                textWriter.WriteLine('}');
                return;
            }
开发者ID:JianwenSun,项目名称:cc,代码行数:86,代码来源:WsdlParser.cs

示例14: PrintClassMethods

            internal override void PrintClassMethods(TextWriter textWriter,
                                                     String indentation,
                                                     String curNS,
                                                     ArrayList printedIFaces,
                                                     bool bProxy,
                                                     StringBuilder sb)
            {
                Util.Log("SystemInterface.PrintClassMethods "+curNS+" bProxy "+bProxy);                             
                // Return if the interfaces have already been printed
                int i;
                for (i=0;i<printedIFaces.Count;i++)
                {
                    if (printedIFaces[i] is SystemInterface)
                    {
                        SystemInterface iface = (SystemInterface) printedIFaces[i];
                        if (iface._type == _type)
                            return;
                    }
                }
                printedIFaces.Add(this);

                // Count of implemented methods
                BindingFlags bFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance |
                                      BindingFlags.Public;// | BindingFlags.NonPublic;
                ArrayList types = new ArrayList();
                sb.Length = 0;
                types.Add(_type);
                i=0;
                int j=1;
                while (i<j)
                {
                    Type type = (Type) types[i];
                    MethodInfo[] methods = type.GetMethods(bFlags);
                    Type[] iFaces = type.GetInterfaces();
                    for (int k=0;k<iFaces.Length;k++)
                    {
                        for (int l=0;l<j;l++)
                        {
                            if (type == iFaces[k])
                                goto Loopback;
                        }
                        types.Add(iFaces[k]);
                        j++;
                        Loopback:
                        continue;
                    }

                    for (int k=0;k<methods.Length;k++)
                    {
                        MethodInfo method = methods[k];
                        sb.Length = 0;
                        sb.Append(indentation);
                        sb.Append(CSharpTypeString(method.ReturnType.FullName));
                        sb.Append(' ');
                        sb.Append(WsdlParser.IsValidCS(type.FullName));
                        sb.Append('.');
                        sb.Append(WsdlParser.IsValidCS(method.Name));
                        sb.Append('(');
                        ParameterInfo[] parameters = method.GetParameters();
                        for (int l=0;l<parameters.Length;l++)
                        {
                            if (l != 0)
                                sb.Append(", ");
                            ParameterInfo param = parameters[l];
                            Type parameterType = param.ParameterType;
                            if (param.IsIn)
                                sb.Append("in ");
                            else if (param.IsOut)
                                sb.Append("out ");
                            else if (parameterType.IsByRef)
                            {
                                sb.Append("ref ");
                                parameterType = parameterType.GetElementType();
                            }
                            sb.Append(CSharpTypeString(parameterType.FullName));
                            sb.Append(' ');
                            sb.Append(WsdlParser.IsValidCS(param.Name));
                        }
                        sb.Append(')');
                        textWriter.WriteLine(sb);

                        textWriter.Write(indentation);
                        textWriter.WriteLine('{');

                        String newIndentation = indentation + "    ";
                        if (bProxy == false)
                        {
                            for (int l=0;l<parameters.Length;l++)
                            {
                                ParameterInfo param = parameters[l];
                                Type parameterType = param.ParameterType;
                                if (param.IsOut)
                                {
                                    sb.Length = 0;
                                    sb.Append(newIndentation);
                                    sb.Append(WsdlParser.IsValidCS(param.Name));
                                    sb.Append(URTMethod.ValueString(CSharpTypeString(param.ParameterType.FullName)));
                                    sb.Append(';');
                                    textWriter.WriteLine(sb);
                                }
//.........这里部分代码省略.........
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:WsdlParser.cs

示例15: WriteEntryProperties

    private void WriteEntryProperties(char[] entryBuffer, string[] select, TextWriter output)
    {
        if (select == null)
        {
          int objectCount = 1;
          for (int i = 1; i < _blockSize; i++)
          {
        switch (entryBuffer[i])
        {
          case '{':
            objectCount++;
            break;

          case '}':
            objectCount--;
            break;
        }

        if (objectCount <= 0)
        {
          break;
        }
        else
        {
          output.Write(entryBuffer[i]);
        }

          }
        }
        else
        {
          int propCount = 0;
          JObject entryJson = JObject.Parse(new String(entryBuffer).Trim());
          foreach (JProperty entryProperty in entryJson.Properties())
          {
        if (select.Contains(entryProperty.Name))
        {
          if (propCount > 0)
          {
            output.Write(',');
          }
          output.Write(entryProperty.ToString(Formatting.None));
          propCount++;
        }
          }
        }
    }
开发者ID:ryanttb,项目名称:restd,代码行数:47,代码来源:ORestd.cs


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