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


C# ITextOutput.WriteLiteral方法代码示例

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


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

示例1: WriteOperand

		public static void WriteOperand(ITextOutput writer, object operand)
		{
			if (operand == null)
				throw new ArgumentNullException("operand");
			
			Instruction targetInstruction = operand as Instruction;
			if (targetInstruction != null) {
				WriteOffsetReference(writer, targetInstruction);
				return;
			}
			
			Instruction[] targetInstructions = operand as Instruction[];
			if (targetInstructions != null) {
				WriteLabelList(writer, targetInstructions);
				return;
			}
			
			Local local = operand as Local;
			if (local != null) {
				if (string.IsNullOrEmpty(local.Name))
					writer.WriteReference("[" + local.Index.ToString() + "]", local, true);
				else
					writer.WriteReference(Escape(local.Name), local, true);
				return;
			}
			
			Parameter param = operand as Parameter;
			if (param != null) {
				if (string.IsNullOrEmpty(param.Name))
					writer.WriteReference("[" + param.Index.ToString() + "]", param, true);
				else
					writer.WriteReference(Escape(param.Name), param, true);
				return;
			}
			
			IMethod methodRef = operand as IMethod;
			if (methodRef != null && dnlibExtensions.IsMethod(methodRef)) {
				methodRef.WriteTo(writer);
				writer.WriteComment(" // 0x" + methodRef.MDToken.Raw.ToString("x8"));
				return;
			}
			
			ITypeDefOrRef typeRef = operand as ITypeDefOrRef;
			if (typeRef != null) {
				typeRef.WriteTo(writer, ILNameSyntax.TypeName);
				writer.WriteComment(" // 0x" + typeRef.MDToken.Raw.ToString("x8"));
				return;
			}

			IField fieldRef = operand as IField;
			if (fieldRef != null && dnlibExtensions.IsField(fieldRef)) {
				fieldRef.WriteTo(writer);
				writer.WriteComment(" // 0x" + fieldRef.MDToken.Raw.ToString("x8"));
				return;
			}
			
			string s = operand as string;
			if (s != null) {
				writer.WriteLiteral("\"" + NRefactory.CSharp.CSharpOutputVisitor.ConvertString(s) + "\"");
			} else if (operand is char) {
				writer.WriteLiteral(((int)(char)operand).ToString());
			} else if (operand is float) {
				float val = (float)operand;
				if (val == 0) {
					if (1 / val == float.NegativeInfinity) {
						// negative zero is a special case
						writer.WriteLiteral("-");
					}
					writer.WriteLiteral("0.0");
				} else if (float.IsInfinity(val) || float.IsNaN(val)) {
					byte[] data = BitConverter.GetBytes(val);
					writer.Write('(');
					for (int i = 0; i < data.Length; i++) {
						if (i > 0)
							writer.WriteLiteral(" ");
						writer.WriteLiteral(data[i].ToString("X2"));
					}
					writer.Write(')');
				} else {
					writer.WriteLiteral(val.ToString("R", System.Globalization.CultureInfo.InvariantCulture));
				}
			} else if (operand is double) {
				double val = (double)operand;
				if (val == 0) {
					if (1 / val == double.NegativeInfinity) {
						// negative zero is a special case
						writer.WriteLiteral("-");
					}
					writer.WriteLiteral("0.0");
				} else if (double.IsInfinity(val) || double.IsNaN(val)) {
					byte[] data = BitConverter.GetBytes(val);
					writer.Write('(');
					for (int i = 0; i < data.Length; i++) {
						if (i > 0)
							writer.WriteLiteral(" ");
						writer.WriteLiteral(data[i].ToString("X2"));
					}
					writer.Write(')');
				} else {
					writer.WriteLiteral(val.ToString("R", System.Globalization.CultureInfo.InvariantCulture));
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:101,代码来源:DisassemblerHelpers.cs


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