Ejemplo n.º 1
0
        public void ShowReference(object reference, DecompilerReferenceFlags flags)
        {
            // System.Console.WriteLine($"{reference}, {reference?.GetType()}, {flags}");
            var ct = this.cts.Token;

            switch (reference)
            {
            case TypeDef typeDef:
                this.DocumentService.Show(typeDef);
                break;

            case TypeRef typeRef:
                Show(this.AssemblyRegistry.ResolveAsync(typeRef, ct), t => this.DocumentService.Show(t), ct);
                break;

            case MethodDef methodDef:
                this.DocumentService.Show(methodDef);
                break;

            case MethodSpec methodSpec:
                Show(this.AssemblyRegistry.ResolveAsync(methodSpec, ct), m => this.DocumentService.Show(m), ct);
                break;

            case FieldDef fieldDef:
                this.DocumentService.Show(fieldDef);
                break;

            case MemberRef memberRef:
                Show(this.AssemblyRegistry.ResolveAsync(memberRef, ct), m => this.DocumentService.Show(m), ct);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Writes text, color and a reference. The text will be indented if needed.
 /// </summary>
 /// <param name="text">Text</param>
 /// <param name="reference">Reference</param>
 /// <param name="flags">Flags</param>
 /// <param name="color">Color, eg. <see cref="BoxedTextColor.Keyword"/></param>
 public virtual void Write(string text, object reference, DecompilerReferenceFlags flags, object color)
 {
     if (addIndent)
     {
         AddIndent();
     }
     AddText(text, color);
 }
Ejemplo n.º 3
0
 public void Write(string text, object reference, DecompilerReferenceFlags flags, object color)
 {
     if (addIndent)
     {
         AddIndent();
     }
     Debug.Assert(reference != null);
     Debug.Assert(!(reference?.GetType().FullName ?? string.Empty).Contains("ICSharpCode"), "Internal decompiler data shouldn't be passed to Write()-ref");
     referenceBuilder.Add(new Span(stringBuilder.Length, text.Length), new ReferenceInfo(reference, flags));
     AddText(text, color);
 }
Ejemplo n.º 4
0
 public override void Write(string text, object reference, DecompilerReferenceFlags flags, object color)
 {
     if (reference == this.reference && (flags & DecompilerReferenceFlags.Definition) != 0 && referenceSpan == null)
     {
         int start = NextPosition;
         base.Write(text, reference, flags, color);
         referenceSpan = new Span(start, Length - start);
     }
     else
     {
         base.Write(text, reference, flags, color);
     }
 }
Ejemplo n.º 5
0
 public void Write(string text, int index, int length, object reference, DecompilerReferenceFlags flags, object color)
 {
     VerifyState(State.GeneratingContent);
     if (addIndent)
     {
         AddIndent();
     }
     if (reference == null)
     {
         AddText(text, index, length, color);
         return;
     }
     Debug.Assert(!(reference.GetType().FullName ?? string.Empty).Contains("ICSharpCode"), "Internal decompiler data shouldn't be passed to Write()-ref");
     referenceBuilder.Add(new Span(stringBuilder.Length, length), new ReferenceInfo(reference, flags));
     AddText(text, index, length, color);
 }
Ejemplo n.º 6
0
        public void Write(string text, object reference, DecompilerReferenceFlags flags, object color)
        {
            if (!this.elementOpened)
            {
                LineStart();
            }

            if (this.addIndent)
            {
                var indent = indenter.String;
                if (indent.Length > 0)
                {
                    this.builder.AddContent(this.NextSequence++, this.indenter.String);
                }
                this.addIndent = false;
            }

            this.builder.OpenElement(this.NextSequence++, "span");
            var cssClass = ColorToCssClass(color);

            if (reference != null && this.eventReceiver != null)
            {
                var _eventReceiver = this.eventReceiver;
                var callback       = EventCallback.Factory.Create <UIMouseEventArgs>(_eventReceiver, () =>
                {
                    _eventReceiver.ShowReference(reference, flags);
                });
                this.builder.AddAttribute <UIMouseEventArgs>(this.NextSequence++, "onclick", callback);
                if (string.IsNullOrEmpty(cssClass))
                {
                    cssClass = "reference";
                }
                else
                {
                    cssClass += " reference";
                }
            }
            if (!string.IsNullOrEmpty(cssClass))
            {
                this.builder.AddAttribute(this.NextSequence++, "class", cssClass);
            }
            this.builder.AddContent(this.NextSequence++, text);
            this.builder.CloseElement();

            Length += text.Length;
        }
 /// <summary>
 /// Writes text, color and a reference. The text will be indented if needed.
 /// </summary>
 /// <param name="text">Text</param>
 /// <param name="index">Index in <paramref name="text"/></param>
 /// <param name="length">Number of characters to write</param>
 /// <param name="reference">Reference</param>
 /// <param name="flags">Flags</param>
 /// <param name="color">Color, eg. <see cref="BoxedTextColor.Keyword"/></param>
 public virtual void Write(string text, int index, int length, object reference, DecompilerReferenceFlags flags, object color) => AddText(text, index, length, color);
Ejemplo n.º 8
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="reference">Reference or null</param>
		/// <param name="flags">Flags</param>
		public TextReference(object reference, DecompilerReferenceFlags flags) {
			Reference = reference;
			Flags = flags;
			Span = null;
		}
Ejemplo n.º 9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="reference">Reference or null</param>
 /// <param name="flags">Flags</param>
 /// <param name="span">Span</param>
 public TextReference(object reference, DecompilerReferenceFlags flags, Span span)
 {
     this.Reference = reference;
     this.Flags     = flags;
     this.Span      = span;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="reference">Reference or null</param>
 /// <param name="flags">Flags</param>
 public TextReference(object reference, DecompilerReferenceFlags flags)
 {
     this.Reference = reference;
     this.Flags     = flags;
     this.Span      = null;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Writes text, color and a reference. The text will be indented if needed.
 /// </summary>
 /// <param name="text">Text</param>
 /// <param name="reference">Reference</param>
 /// <param name="flags">Flags</param>
 /// <param name="color">Color, eg. <see cref="BoxedTextColor.Keyword"/></param>
 public void Write(string text, object reference, DecompilerReferenceFlags flags, object color) => AddText(text, color);
Ejemplo n.º 12
0
 void IDecompilerOutput.Write(string text, object reference, DecompilerReferenceFlags flags, object color) =>
 ((IDecompilerOutput)this).Write(text, color);
Ejemplo n.º 13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="reference">Reference or null</param>
 /// <param name="flags">Flags</param>
 /// <param name="span">Span</param>
 public TextReference(object reference, DecompilerReferenceFlags flags, Span span)
 {
     Reference = reference;
     Flags     = flags;
     Span      = span;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="reference">Reference or null</param>
 /// <param name="flags">Flags</param>
 public TextReference(object reference, DecompilerReferenceFlags flags)
 {
     Reference = reference;
     Flags     = flags;
     Span      = null;
 }
Ejemplo n.º 15
0
 public void Write(string text, int index, int length, object reference, DecompilerReferenceFlags flags, object color)
 {
     Write(text.Substring(index, length), reference, flags, color);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="reference">Reference or null</param>
 /// <param name="flags">Flags</param>
 public ReferenceInfo(object reference, DecompilerReferenceFlags flags)
 {
     Reference = reference;
     Flags     = flags;
 }
Ejemplo n.º 17
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="reference">Reference or null</param>
		/// <param name="flags">Flags</param>
		/// <param name="span">Span</param>
		public TextReference(object reference, DecompilerReferenceFlags flags, Span span) {
			Reference = reference;
			Flags = flags;
			Span = span;
		}
Ejemplo n.º 18
0
 public override void Write(string text, object reference, DecompilerReferenceFlags flags, object color) =>
 Write(text, 0, text.Length, reference, flags, color);
 public void Write(string text, int index, int length, object reference, DecompilerReferenceFlags flags, object color) => implementation.Write(Modify(text, reference), index, length, reference, flags, color);
Ejemplo n.º 20
0
 void IDecompilerOutput.Write(string text, int index, int length, object?reference, DecompilerReferenceFlags flags, object color) =>
 ((IDecompilerOutput)this).Write(text, index, length, color);
Ejemplo n.º 21
0
 public void Write(string text, object?reference, DecompilerReferenceFlags flags, object color) => implementation.Write(Modify(text, reference), reference, flags, color);