本文整理汇总了C#中ITextOutput类的典型用法代码示例。如果您正苦于以下问题:C# ITextOutput类的具体用法?C# ITextOutput怎么用?C# ITextOutput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITextOutput类属于命名空间,在下文中一共展示了ITextOutput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTo
public static void WriteTo(this ExceptionHandler exceptionHandler, ITextOutput writer, MethodDef method)
{
writer.Write("Try", TextTokenType.Keyword);
writer.WriteSpace();
WriteOffsetReference(writer, exceptionHandler.TryStart, method);
writer.Write('-', TextTokenType.Operator);
WriteOffsetReference(writer, exceptionHandler.TryEnd, method);
writer.WriteSpace();
writer.Write(exceptionHandler.HandlerType.ToString(), TextTokenType.Keyword);
if (exceptionHandler.FilterStart != null) {
writer.WriteSpace();
WriteOffsetReference(writer, exceptionHandler.FilterStart, method);
writer.WriteSpace();
writer.Write("handler", TextTokenType.Keyword);
writer.WriteSpace();
}
if (exceptionHandler.CatchType != null) {
writer.WriteSpace();
exceptionHandler.CatchType.WriteTo(writer);
}
writer.WriteSpace();
WriteOffsetReference(writer, exceptionHandler.HandlerStart, method);
writer.Write('-', TextTokenType.Operator);
WriteOffsetReference(writer, exceptionHandler.HandlerEnd, method);
}
示例2: Write
protected override void Write(ITextOutput output, Language language)
{
if (name != null)
output.Write(name, TextTokenType.Keyword);
else
base.Write(output, language);
}
示例3: AcceptWriter
public override void AcceptWriter(ITextOutput writer)
{
List<string> keyList = new List<string>(Values.Keys);
int keyCount = keyList.Count;
JsonValue jsonValue;
bool isFirst = true;
for (int i = 0; i < keyCount; i++)
{
if (isFirst)
{
writer.Write('{');
isFirst = false;
}
else
{
writer.Write(", ");
}
writer.Write('"');
writer.Write(keyList[i]);
writer.Write('"');
writer.Write(':');
if (Values.TryGetValue(keyList[i], out jsonValue))
{
jsonValue.AcceptWriter(writer);
}
}
if (!isFirst)
writer.Write('}');
}
示例4: DecompileMethod
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
WriteCommentLine(output, TypeToString(method.DeclaringType, includeNamespace: true));
AstBuilder codeDomBuilder = CreateAstBuilder(options, method.DeclaringType);
codeDomBuilder.AddMethod(method);
codeDomBuilder.GenerateCode(output, transformAbortCondition);
}
示例5: DecompileAssembly
public override void DecompileAssembly(AssemblyDefinition assembly, string fileName, ITextOutput output, DecompilationOptions options)
{
output.WriteLine("// " + fileName);
output.WriteLine();
new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken).WriteAssemblyHeader(assembly);
}
示例6: WriteTo
public static void WriteTo(this Instruction instruction, ITextOutput writer, Func<OpCode, string> getOpCodeDocumentation)
{
writer.WriteDefinition(DnlibExtensions.OffsetToString(instruction.GetOffset()), instruction, TextTokenType.Label, false);
writer.Write(':', TextTokenType.Operator);
writer.WriteSpace();
writer.WriteReference(instruction.OpCode.Name, instruction.OpCode, TextTokenType.OpCode);
if (instruction.Operand != null) {
writer.WriteSpace();
if (instruction.OpCode == OpCodes.Ldtoken) {
var member = instruction.Operand as IMemberRef;
if (member != null && member.IsMethod) {
writer.Write("method", TextTokenType.Keyword);
writer.WriteSpace();
}
else if (member != null && member.IsField) {
writer.Write("field", TextTokenType.Keyword);
writer.WriteSpace();
}
}
WriteOperand(writer, instruction.Operand);
}
if (getOpCodeDocumentation != null) {
var doc = getOpCodeDocumentation(instruction.OpCode);
if (doc != null) {
writer.Write("\t", TextTokenType.Text);
writer.Write("// " + doc, TextTokenType.Comment);
}
}
}
示例7: CppTextOutputFormatter
public CppTextOutputFormatter(ITextOutput output)
{
if (output == null)
throw new ArgumentNullException("output");
this.output = output;
this.IndentationString = "\t";
}
示例8: Write
public static ITextOutput Write(ITextOutput output, MethodDef method, Language language) {
output.Write(UIUtils.CleanUpIdentifier(method.Name), TextTokenHelper.GetTextTokenType(method));
output.Write('(', TextTokenType.Operator);
for (int i = 0; i < method.Parameters.Count; i++) {
if (method.Parameters[i].IsHiddenThisParameter)
continue;
if (method.Parameters[i].MethodSigIndex > 0) {
output.Write(',', TextTokenType.Operator);
output.WriteSpace();
}
language.TypeToString(output, method.Parameters[i].Type.ToTypeDefOrRef(), false, method.Parameters[i].ParamDef);
}
if (method.CallingConvention == CallingConvention.VarArg || method.CallingConvention == CallingConvention.NativeVarArg) {
if (method.MethodSig.GetParamCount() > 0) {
output.Write(',', TextTokenType.Operator);
output.WriteSpace();
}
output.Write("...", TextTokenType.Operator);
}
output.Write(')', TextTokenType.Operator);
output.WriteSpace();
output.Write(':', TextTokenType.Operator);
output.WriteSpace();
language.TypeToString(output, method.ReturnType.ToTypeDefOrRef(), false, method.Parameters.ReturnParameter.ParamDef);
method.MDToken.WriteSuffixString(output);
return output;
}
示例9: DecompileMethod
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
if (!method.HasBody) {
return;
}
ILAstBuilder astBuilder = new ILAstBuilder();
ILBlock ilMethod = new ILBlock();
ilMethod.Body = astBuilder.Build(method, inlineVariables);
if (abortBeforeStep != null) {
DecompilerContext context = new DecompilerContext(method.Module) { CurrentType = method.DeclaringType, CurrentMethod = method };
new ILAstOptimizer().Optimize(context, ilMethod, abortBeforeStep.Value);
}
var allVariables = ilMethod.GetSelfAndChildrenRecursive<ILExpression>().Select(e => e.Operand as ILVariable)
.Where(v => v != null && !v.IsParameter).Distinct();
foreach (ILVariable v in allVariables) {
output.WriteDefinition(v.Name, v);
if (v.Type != null) {
output.Write(" : ");
if (v.IsPinned)
output.Write("pinned ");
v.Type.WriteTo(output, ILNameSyntax.ShortTypeName);
}
output.WriteLine();
}
output.WriteLine();
foreach (ILNode node in ilMethod.Body) {
node.WriteTo(output);
output.WriteLine();
}
}
示例10: VBTextOutputFormatter
public VBTextOutputFormatter(ITextOutput output, VBFormattingOptions formattingPolicy)
{
if (output == null)
throw new ArgumentNullException("output");
this.output = output;
this.policy = formattingPolicy;
}
示例11: Decompile
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(EnsureChildrenFiltered));
foreach (ILSpyTreeNode child in this.Children) {
child.Decompile(language, output, options);
}
}
示例12: Decompile
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
EnsureChildrenFiltered();
base.Decompile(language, output, options);
if (stringTableEntries.Count != 0) {
ISmartTextOutput smartOutput = output as ISmartTextOutput;
if (null != smartOutput) {
smartOutput.AddUIElement(
delegate {
var textView = options.DecompilerTextView;
if (textView != null)
return new ResourceStringTable(stringTableEntries, textView) { Cursor = Cursors.Arrow };
return new TextBlock { Text = "no active tab!" };
}
);
}
output.WriteLine();
output.WriteLine();
}
if (otherEntries.Count != 0) {
ISmartTextOutput smartOutput = output as ISmartTextOutput;
if (null != smartOutput) {
smartOutput.AddUIElement(
delegate {
var textView = options.DecompilerTextView;
if (textView != null)
return new ResourceObjectTable(otherEntries, textView) { Cursor = Cursors.Arrow };
return new TextBlock { Text = "no active tab!" };
}
);
}
output.WriteLine();
}
}
示例13: DecompileMethod
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
WriteCommentLine(output, TypeToString(method.DeclaringType, includeNamespace: true));
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentType: method.DeclaringType, isSingleMember: true);
codeDomBuilder.AddMethod(method);
RunTransformsAndGenerateCode(codeDomBuilder, output, options, method.Module);
}
示例14: DecompileMethod
public override void DecompileMethod(ilspy::Mono.Cecil.MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
var xMethod = GetXMethodDefinition(method);
var ilMethod = xMethod as XBuilder.ILMethodDefinition;
CompiledMethod cmethod;
if (ilMethod == null || !ilMethod.OriginalMethod.HasBody)
{
output.Write("");
output.WriteLine("// not an il method or method without body.");
return;
}
var methodSource = new MethodSource(xMethod, ilMethod.OriginalMethod);
var target = (DexTargetPackage) AssemblyCompiler.TargetPackage;
var dMethod = (MethodDefinition)xMethod.GetReference(target);
DexMethodBodyCompiler.TranslateToRL(AssemblyCompiler, target, methodSource, dMethod, GenerateSetNextInstructionCode, out cmethod);
var rlBody = cmethod.RLBody;
// Optimize RL code
string lastApplied = RLTransformations.Transform(target.DexFile, rlBody, StopOptimizationAfter == -1?int.MaxValue:StopOptimizationAfter);
if(lastApplied != null)
output.WriteLine("// Stop after " + lastApplied);
PrintMethod(cmethod, output, options);
}
示例15: Decompile
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
EnsureLazyChildren();
base.Decompile(language, output, options);
if (stringTableEntries.Count != 0) {
ISmartTextOutput smartOutput = output as ISmartTextOutput;
if (null != smartOutput) {
smartOutput.AddUIElement(
delegate {
return new ResourceStringTable(stringTableEntries,
new System.Windows.Size(MainWindow.Instance.mainPane.ActualWidth - 45,
MainWindow.Instance.mainPane.ActualHeight));
}
);
}
output.WriteLine();
output.WriteLine();
}
if (otherEntries.Count != 0) {
ISmartTextOutput smartOutput = output as ISmartTextOutput;
if (null != smartOutput) {
smartOutput.AddUIElement(
delegate {
return new ResourceObjectTable(otherEntries,
new System.Windows.Size(MainWindow.Instance.mainPane.ActualWidth - 45,
MainWindow.Instance.mainPane.ActualHeight));
}
);
}
output.WriteLine();
}
}