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


C# TextWriter.Write方法代码示例

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


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

示例1: DumpNode

		private void DumpNode(HuffmanNode node,string tag, int i, TextWriter writer)
		{
			for (int j = 0; j < i; j++)
			{
				writer.Write("    ");
			}
			writer.Write('-');

			if (node.IsBranch)
				writer.Write(" {0} '{2}' x {1:4} = ", tag, node.Freq, (char)node.Symbol);
			else
				writer.Write(" {1} Freq {0} = ", node.Freq, tag);

			if (node.IsBranch == false)
			{
				foreach (var bit in node.Bits)
				{
					writer.Write(bit ? "1" : "0");
				}
			}

			writer.WriteLine();

			if (node.IsBranch == false)
				return;
			DumpNode(node.Left, "left", i+1, writer);
			DumpNode(node.Right, "right", i + 1, writer);
		}
开发者ID:modulexcite,项目名称:Rhea.Compression,代码行数:28,代码来源:HuffmanTable.cs

示例2: Encode

        /// <summary>
        /// Entry point to the encoder.
        /// </summary>
        public void Encode(char[] value, int startIndex, int characterCount, TextWriter output)
        {
            // Input checking
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            ValidateInputs(startIndex, characterCount, actualInputLength: value.Length);

            if (characterCount != 0)
            {
                fixed (char* pChars = value)
                {
                    int indexOfFirstCharWhichRequiresEncoding = GetIndexOfFirstCharWhichRequiresEncoding(&pChars[startIndex], characterCount);
                    if (indexOfFirstCharWhichRequiresEncoding < 0)
                    {
                        // All chars are valid - just copy the buffer as-is.
                        output.Write(value, startIndex, characterCount);
                    }
                    else
                    {
                        // Flush all chars which are known to be valid, then encode the remainder individually
                        if (indexOfFirstCharWhichRequiresEncoding > 0)
                        {
                            output.Write(value, startIndex, indexOfFirstCharWhichRequiresEncoding);
                        }
                        EncodeCore(&pChars[startIndex + indexOfFirstCharWhichRequiresEncoding], (uint)(characterCount - indexOfFirstCharWhichRequiresEncoding), output);
                    }
                }
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:38,代码来源:UnicodeEncoderBase.cs

示例3: Write

 public void Write(TextWriter writer)
 {
     writer.Write("{0} ", Address.ToLinear());
     bool inString = false;
     for (int i = 0; i < Line.Length; ++i)
     {
         int b = Line[i];
         if (inString)
         {
             writer.Write(Encoding.UTF8.GetString(Line, i, 1));
             inString = (b != 0x22);
         }
         else
         {
             if (TokenMin <= b && b < TokenMax)
             {
                 writer.Write(TokenStrs[b - TokenMin]);
             }
             else
             {
                 writer.Write(Encoding.UTF8.GetString(Line, i, 1));
             }
             inString = (b == 0x22);
         }
     }
     writer.WriteLine();
 }
开发者ID:melbcat,项目名称:reko,代码行数:27,代码来源:C64BasicInstruction.cs

示例4: GetPacketDataString

 public override void GetPacketDataString(TextWriter text, bool flagsDescription)
 {
     text.Write("regionIndex:0x{0:X2} region:{1,-3} serverIp:\"{2}\" portFrom:{3} portTo:{4}",
          regionIndex, region, serverIp, portFrom, portTo);
     if (flagsDescription)
         text.Write(" zoneInfo:\"{0}\"", zoneInfo);
 }
开发者ID:Dawn-of-Light,项目名称:PacketLogConverter,代码行数:7,代码来源:StoC_0xB1_StartArena.cs

示例5: GenerateDummies

        static void GenerateDummies(TextWriter @out)
        {
            @out.Write(@"
            namespace Dummies {

            #region Interfaces

            ");
            string dummyFace = " interface IDummy{0} : IDummy {{ void DoMore(); }}\r\n";
            string dummyBody = @"
            public class SimpleDummy{0} : IDummy{1} {{
            public SimpleDummy{0}() {{}}
            public void Do() {{}}
            public void DoMore() {{}}
            }}
            ";
            for (var i = 0; i < NUM_I; i++) {
                @out.Write(dummyFace, i);
            }

            @out.Write(@"
            #endregion
            #region Implementation\r\n");
            int K = NUM_I * K_TO_I;
            for (var k = 0; k < K ; k++) {
                int i = k / K_TO_I;
                @out.Write(dummyBody, k, i);
            }

            @out.Write(@"
            #endregion
            }");
        }
开发者ID:philipmat,项目名称:di_speed,代码行数:33,代码来源:Program.cs

示例6: ToSqlInsert

        public void ToSqlInsert(TextWriter writer)
        {
            foreach (var id in _comments.Keys)
                writer.Write("-- {0} => {1}{2}", id, _comments[id], Environment.NewLine);

            writer.WriteLine();
            writer.Write("insert into conditions values");

            var last = _conditions.Last();

            var conditions = from c1 in _conditions
                             from c2 in c1.Conditions
                             select c2;

            foreach (var condition in conditions)
            {
                writer.Write(
                    "{0}  {1}{2}",
                    Environment.NewLine,
                    condition.ToString(),
                    condition == last ? ";" : ",");
            }

            writer.WriteLine();
            writer.Flush();
        }
开发者ID:vermie,项目名称:MangosUtil,代码行数:26,代码来源:SqlScript.cs

示例7:

		/// <summary>
		/// Describes this object.
		/// </summary>
		/// <param name="writer">The text writer the description is added to.</param>
		void ISelfDescribing.DescribeTo(TextWriter writer)
		{
			writer.Write("set ");
			writer.Write(name);
			writer.Write("=");
			writer.Write(value);
		}
开发者ID:textmetal,项目名称:main,代码行数:11,代码来源:SetNamedParameterAction.cs

示例8: Serialize

		public static void Serialize(bool value, TextWriter sw)
		{
			if (value)
				sw.Write("true");
			else
				sw.Write("false");
		}
开发者ID:dstimac,项目名称:revenj,代码行数:7,代码来源:BoolConverter.cs

示例9: Convert

		/// <summary>
		/// Write the current thread identity to the output
		/// </summary>
		/// <param name="writer">the writer to write to</param>
		/// <param name="state">null, state is not set</param>
		/// <remarks>
		/// <para>
		/// Writes the current thread identity to the output <paramref name="writer"/>.
		/// </para>
		/// </remarks>
		override protected void Convert(TextWriter writer, object state) 
		{
#if (NETCF || SSCLI)
			// On compact framework there's no notion of current thread principals
			writer.Write( SystemInfo.NotAvailableText );
#else
			try
			{
				if (System.Threading.Thread.CurrentPrincipal != null && 
					System.Threading.Thread.CurrentPrincipal.Identity != null &&
					System.Threading.Thread.CurrentPrincipal.Identity.Name != null)
				{
					writer.Write( System.Threading.Thread.CurrentPrincipal.Identity.Name );
				}
			}
			catch(System.Security.SecurityException)
			{
				// This security exception will occur if the caller does not have 
				// some undefined set of SecurityPermission flags.
				LogLog.Debug(declaringType, "Security exception while trying to get current thread principal. Error Ignored.");

				writer.Write( SystemInfo.NotAvailableText );
			}
#endif
		}
开发者ID:j2m2,项目名称:CmisSync,代码行数:35,代码来源:IdentityPatternConverter.cs

示例10: PrintMethodAllocationsPerClass

		static void PrintMethodAllocationsPerClass (TextWriter writer, LoadedClass.AllocationsPerMethod allocationsPerMethod, bool JitTime, bool printStackTraces, double stackTraceTreshold) {
			if (! JitTime) {
				writer.WriteLine ("        {0} bytes ({1} instances) from {2}.{3}", allocationsPerMethod.AllocatedBytes, allocationsPerMethod.AllocatedInstances, allocationsPerMethod.Method.Class.Name, allocationsPerMethod.Method.Name);
			} else {
				writer.WriteLine ("                {0} bytes ({1} instances) at JIT time in {2}.{3}", allocationsPerMethod.AllocatedBytes, allocationsPerMethod.AllocatedInstances, allocationsPerMethod.Method.Class.Name, allocationsPerMethod.Method.Name);
			}
			
			if (printStackTraces) {
				LoadedClass.AllocationsPerStackTrace [] stackTraces = allocationsPerMethod.StackTraces;
				Array.Sort (stackTraces, LoadedClass.AllocationsPerStackTrace.CompareByAllocatedBytes);
				Array.Reverse (stackTraces);
				double cumulativeAllocatedBytesPerStackTrace = 0;
				
				foreach (LoadedClass.AllocationsPerStackTrace trace in stackTraces) {
					if (cumulativeAllocatedBytesPerStackTrace / allocationsPerMethod.AllocatedBytes < stackTraceTreshold) {
						writer.WriteLine ("                {0} bytes ({1} instances) inside", trace.AllocatedBytes, trace.AllocatedInstances);
						for (StackTrace frame = trace.Trace; frame != null; frame = frame.Caller) {
							writer.Write ("                        ");
							if (frame.MethodIsBeingJitted) {
								writer.Write ("[JIT time]:");
							}
							writer.WriteLine ("{0}.{1}", frame.TopMethod.Class.Name, frame.TopMethod.Name);
						}
					} else {
						break;
					}
					cumulativeAllocatedBytesPerStackTrace += (double)trace.AllocatedBytes;
				}
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:30,代码来源:Main.cs

示例11: Source

 public void Source(ISetting setting, TextWriter output)
 {
     output.Write (setting.BlockBegin);
     output.Write ("dump ");
     output.Write (this.expression);
     output.Write (setting.BlockEnd);
 }
开发者ID:r3c,项目名称:cottle,代码行数:7,代码来源:DumpNode.cs

示例12:

		/// <summary>
		/// Describes this object.
		/// </summary>
		/// <param name="writer">The text writer the description is added to.</param>
		void ISelfDescribing.DescribeTo(TextWriter writer)
		{
			writer.Write("set arg ");
			writer.Write(index);
			writer.Write("=");
			writer.Write(value);
		}
开发者ID:textmetal,项目名称:main,代码行数:11,代码来源:SetIndexedParameterAction.cs

示例13: RenderExceptionData

        private void RenderExceptionData(RendererMap rendererMap, Exception ex, TextWriter writer, int depthLevel)
        {
            var dataCount = ex.Data.Count;
            if (dataCount == 0)
            {
                return;
            }

            writer.WriteLine();

            writer.WriteLine($"Exception data on level {depthLevel} ({dataCount} items):");

            var currentElement = 0;
            foreach (DictionaryEntry entry in ex.Data)
            {
                currentElement++;

                writer.Write("[");
                ExceptionObjectLogger.RenderValue(rendererMap, writer, entry.Key);
                writer.Write("]: ");

                ExceptionObjectLogger.RenderValue(rendererMap, writer, entry.Value);

                if (currentElement < dataCount)
                {
                    writer.WriteLine();
                }
            }
        }
开发者ID:SeriousM,项目名称:BugTracker,代码行数:29,代码来源:ExceptionObjectLogger.cs

示例14: DebugDump

        public void DebugDump(TextWriter writer, Story story)
        {
            if (Name.Length > 0)
            {
                if (Negate) writer.Write("!");
                writer.Write("{0}(", Name);
                if (Parameters != null)
                {
                    for (var i = 0; i < Parameters.Count; i++)
                    {
                        Parameters[i].DebugDump(writer, story);
                        if (i < Parameters.Count - 1) writer.Write(", ");
                    }
                }

                writer.Write(") ");
            }

            if (GoalIdOrDebugHook != 0)
            {
                if (GoalIdOrDebugHook < 0)
                {
                    writer.Write("<Debug hook #{0}>", -GoalIdOrDebugHook);
                }
                else
                {
                    var goal = story.Goals[(uint)GoalIdOrDebugHook];
                    writer.Write("<Complete goal #{0} {1}>", GoalIdOrDebugHook, goal.Name);
                }
            }
        }
开发者ID:Norbyte,项目名称:lslib,代码行数:31,代码来源:Call.cs

示例15: print

	/**
	 * Prettyprint the object to the outputstream.
	 */
	public static void print(object o, TextWriter w, bool typeheader) {
		if (o == null) {
			if(typeheader) w.WriteLine("null object");
			w.WriteLine("null");
			w.Flush();
			return;
		}

		if (o is IDictionary) {
			if(typeheader) w.WriteLine("hashtable");
			IDictionary map=(IDictionary)o;
			w.Write("{");
			foreach(object key in map.Keys) {
				w.Write(key.ToString()+"="+map[key].ToString()+", ");
			}
			w.WriteLine("}");
		} else if (o is string) {
			if(typeheader) w.WriteLine("String");
			w.WriteLine(o.ToString());
		} else if (o is DateTime) {
			if(typeheader) w.WriteLine("DateTime");
			w.WriteLine((DateTime)o);
		} else if (o is IEnumerable) {
			if(typeheader) w.WriteLine(o.GetType().Name);
			writeEnumerable(o, w);
			w.WriteLine("");
		} else {
			if(typeheader) w.WriteLine(o.GetType().Name);
			w.WriteLine(o.ToString());
		}
		
		w.Flush();
	}
开发者ID:davies,项目名称:Pyrolite,代码行数:36,代码来源:PrettyPrint.cs


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