ソースを参照

update subscriber page.

master
yangxiaodong 7年前
コミット
08f558a337
3個のファイルの変更66行の追加25行の削除
  1. +51
    -17
      src/DotNetCore.CAP/Dashboard/HtmlHelper.cs
  2. +5
    -1
      src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.cshtml
  3. +10
    -7
      src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.generated.cs

+ 51
- 17
src/DotNetCore.CAP/Dashboard/HtmlHelper.cs ファイルの表示

@@ -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


+ 5
- 1
src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.cshtml ファイルの表示

@@ -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++;


+ 10
- 7
src/DotNetCore.CAP/Dashboard/Pages/SubscriberPage.generated.cs ファイルの表示

@@ -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"
}



読み込み中…
キャンセル
保存