Commit 08f558a3 authored by yangxiaodong's avatar yangxiaodong

update subscriber page.

parent 01d92064
......@@ -10,6 +10,7 @@ using DotNetCore.CAP.Dashboard.Resources;
using DotNetCore.CAP.Dashboard.Pages;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Models;
using Microsoft.Extensions.Internal;
namespace DotNetCore.CAP.Dashboard
{
......@@ -222,11 +223,24 @@ namespace DotNetCore.CAP.Dashboard
{
var outputString = string.Empty;
var @public = "<span style=\"color:blue\">public </span>";
var @public = WrapKeyword("public");
var @async = string.Empty;
var @return = string.Empty;
var key = Hignlight(method.ReturnType);
var isAwaitable = CoercedAwaitableInfo.IsTypeAwaitable(method.ReturnType, out var coercedAwaitableInfo);
if (isAwaitable)
{
@async = WrapKeyword("async");
var asyncResultType = coercedAwaitableInfo.AwaitableInfo.ResultType;
var name = method.Name;
@return = WrapType("Task") + WrapIdentifier("<") + WrapType(asyncResultType) + WrapIdentifier(">");
}
else
{
@return = WrapType(method.ReturnType);
}
var @name = method.Name;
string paramType = null;
string paramName = null;
......@@ -237,52 +251,72 @@ namespace DotNetCore.CAP.Dashboard
{
var firstParam = @params[0];
var firstParamType = firstParam.ParameterType;
paramType = Hignlight(firstParamType);
paramType = WrapType(firstParamType);
paramName = firstParam.Name;
}
if (paramType == null)
{
paramString = "(){ }";
paramString = "();";
}
else
{
paramString = $"({paramType} {paramName}){{ }}";
paramString = $"({paramType} {paramName});";
}
outputString = @public + " " + (string.IsNullOrEmpty(@async) ? "" : @async + " ") + @return + " " + @name + paramString;
outputString = @public + key + name + paramString;
return new NonEscapedString(outputString);
}
public string Hignlight(Type type)
private string WrapType(Type type)
{
if(type.Name == "Void")
if (type == null)
{
return string.Empty;
}
if (type.Name == "Void")
{
return HighligthKey(type.Name.ToLower());
return WrapKeyword(type.Name.ToLower());
}
if (Helper.IsComplexType(type))
{
return HighligthClass(type.Name);
return WrapType(type.Name);
}
if (type.IsPrimitive || type.Equals(typeof(string)) || type.Equals(typeof(decimal)))
{
return HighligthKey(type.Name.ToLower());
return WrapKeyword(type.Name.ToLower());
}
else
{
return HighligthClass(type.Name);
return WrapType(type.Name);
}
}
private string HighligthClass(string key)
private string WrapIdentifier(string value)
{
return value;
}
private string WrapKeyword(string value)
{
return Span("keyword", value);
}
private string WrapType(string value)
{
return Span("type", value);
}
private string WrapString(string value)
{
return $"<span style=\"color:#07c1be\">{key} </span>";
return Span("string", value);
}
private string HighligthKey(string key)
private string Span(string @class, string value)
{
return $"<span style=\"color:blue\">{key} </span>";
return $"<span class=\"{@class}\">{value}</span>";
}
//private static readonly StackTraceHtmlFragments StackTraceHtmlFragments = new StackTraceHtmlFragments
......
......@@ -48,7 +48,11 @@
<td>@column.Attribute.Name</td>
<td>
<span style="color:#00bcd4">@column.ImplTypeInfo.Name</span>:
@Html.MethodEscaped(column.MethodInfo)
<div class="job-snippet-code">
<code>
<pre>@Html.MethodEscaped(column.MethodInfo)</pre>
</code>
</div>
</td>
</tr>
i++;
......
......@@ -229,23 +229,26 @@ WriteLiteral("</td>\r\n <td>\r\n
#line default
#line hidden
WriteLiteral("</span>:\r\n ");
WriteLiteral("</span>:\r\n <div class=\"job-snippet-code\">\r" +
"\n <code>\r\n " +
" <pre>");
#line 51 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write(Html.MethodEscaped(column.MethodInfo));
#line 53 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
Write(Html.MethodEscaped(column.MethodInfo));
#line default
#line hidden
WriteLiteral("\r\n </td>\r\n </tr" +
">\r\n");
WriteLiteral("</pre>\r\n </code>\r\n " +
" </div>\r\n </td>\r\n " +
" </tr>\r\n");
#line 54 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
#line 58 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
i++;
}
}
......@@ -257,7 +260,7 @@ WriteLiteral(" </tbody>\r\n </table>\r\n
#line 60 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
#line 64 "..\..\Dashboard\Pages\SubscriberPage.cshtml"
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment