ProcessorMetaDescriptor.cshtml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. @using Edge.Core.Processor;
  2. @using System.Reflection;
  3. @using Edge.Core.Processor.Dispatcher;
  4. @model IEnumerable<ProcessorMetaDescriptor>;
  5. @{
  6. ViewData["Title"] = "Meta Api - Active Processor meta config";
  7. }
  8. <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">
  9. <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-exp.min.css">
  10. <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-icons.min.css">
  11. <script src="https://cdn.jsdelivr.net/npm/@@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script>
  12. <div class="text-center">
  13. <h4 class="display-4">Processor Meta Descriptor</h4>
  14. <h5>当前加载的 Processors 分别由什么 MetaParts 组成, 以及它们的初始参数</h5>
  15. </div>
  16. <div>
  17. <p>CurrentDomain Assemblies count: @ObjectInstanceCreator.CurrentDomainAssemblies.Count(), ProcessorEndPointTypes(meta descriptor Entrance) count: @ObjectInstanceCreator.CurrentDomainProcessorEndPointTypes.ExtractProcessorMetaDescriptor().Count(), showing count: @Model.Count()</p>
  18. <ul>
  19. @foreach (var pMetaDescriptor in Model)
  20. {
  21. <li>
  22. <b>@pMetaDescriptor.SourceEndpointFullTypeStr - @pMetaDescriptor.Type</b><br />
  23. <blockquote>
  24. <p>DisplayName: @pMetaDescriptor.DisplayName</p>
  25. <p>Description: @pMetaDescriptor.Description</p>
  26. <p>Tags: <i>@(pMetaDescriptor.Tags?.Aggregate((acc, n) => acc + ", " + n)??"")</i></p>
  27. </blockquote>
  28. MetaParts(@pMetaDescriptor.MetaPartsGroupDescriptors.Count() types):
  29. <br />
  30. <ul>
  31. @foreach (var partsDescriptorGroup in pMetaDescriptor.MetaPartsGroupDescriptors)//.GroupBy(g => g.GroupType))
  32. {
  33. <li>
  34. @partsDescriptorGroup.GroupType (1 of below <b>@partsDescriptorGroup.MetaPartsDescriptors.Count()</b> types are support)<br />
  35. <ul>
  36. @foreach (var partsDescriptor in partsDescriptorGroup.MetaPartsDescriptors)
  37. {
  38. <li>
  39. @partsDescriptor.FullTypeString<br />
  40. <blockquote>
  41. <p>DisplayName: @partsDescriptor.DisplayName</p>
  42. <p>Description: @partsDescriptor.Description</p>
  43. </blockquote>
  44. 此 MetaParts 的初始化入口有 <b>@partsDescriptor.ParametersJsonSchemaStrings.Count()</b> 种方式,分列其 parameters json schemas 如下:<br />
  45. <ul>
  46. @for (int ctorIndex = 0; ctorIndex < partsDescriptor.ParametersJsonSchemaStrings.Count(); ctorIndex++)
  47. {
  48. var uniquePartsTypeStr = (pMetaDescriptor.SourceEndpointFullTypeStr + "_" + partsDescriptor.TypeString)
  49. .Replace(".", "__")
  50. .Replace(", ", "___")
  51. .Replace("=", "_")
  52. .Replace("<", "___left").Replace(">", "___right")
  53. .Replace("`", "___generic")
  54. .Replace("+", "___plus___");
  55. var uniqueCtorSubmitButtonId = uniquePartsTypeStr +
  56. "_CtorIndex" + ctorIndex;
  57. var ctorJsonSchemaStrings = partsDescriptor.ParametersJsonSchemaStrings.ElementAt(ctorIndex);
  58. <li>
  59. 第 @(ctorIndex + 1) 种初始化入口参数 json schema str 列表:
  60. <ul>
  61. @for (int paramIndex = 0; paramIndex < ctorJsonSchemaStrings.Count; paramIndex++)
  62. {
  63. var paramSchemaStr = ctorJsonSchemaStrings[paramIndex];
  64. //change this must align with bottom part
  65. var editorHolderId = "editor_holder" + "_CtorIndex" + ctorIndex +
  66. "_ParamIndex" + paramIndex + "_" + uniquePartsTypeStr;
  67. <li>
  68. @paramSchemaStr
  69. <div id='@editorHolderId' style="border:double;padding:2px"></div>
  70. </li>
  71. }
  72. </ul>
  73. <div>
  74. <div style="margin-top:5px"><button id='@uniqueCtorSubmitButtonId'>Validate&Submit (console.log)</button></div>
  75. <script>
  76. var singleCtorJsonEditors_@uniqueCtorSubmitButtonId = [];
  77. @for (int paramIndex = 0; paramIndex < ctorJsonSchemaStrings.Count; paramIndex++)
  78. {
  79. var paramSchemaStr = ctorJsonSchemaStrings[paramIndex];
  80. var editorHolderId = "editor_holder" + "_CtorIndex" + ctorIndex +
  81. "_ParamIndex" + paramIndex + "_" + uniquePartsTypeStr;
  82. @:// Initialize the editor with a JSON schema
  83. @:var editor_@editorHolderId =
  84. @: new JSONEditor(
  85. @: document.getElementById('@editorHolderId'),
  86. @: {
  87. @: theme: 'spectre',
  88. @: iconlib: "spectre",
  89. @: disable_edit_json: true,
  90. @: disable_array_reorder: true,
  91. @: array_controls_top: true,
  92. @: disable_collapse: true,
  93. @: disable_properties: true,
  94. @: schema: @Html.Raw(paramSchemaStr)
  95. @: });
  96. @:(singleCtorJsonEditors_@uniqueCtorSubmitButtonId).push(editor_@editorHolderId);
  97. }
  98. // Hook up the submit button to log to the console
  99. document.getElementById('@uniqueCtorSubmitButtonId').addEventListener('click', function () {
  100. // Get the value from the editor
  101. var singleCtorJsonValues_@uniqueCtorSubmitButtonId = [];
  102. (singleCtorJsonEditors_@uniqueCtorSubmitButtonId).forEach(function (editor, index, array) {
  103. const errors = editor.validate();
  104. if (errors.length) {
  105. // errors is an array of objects, each with a `path`, `property`, and `message` parameter
  106. // `property` is the schema keyword that triggered the validation error (e.g. "minLength")
  107. // `path` is a dot separated path into the JSON object (e.g. "root.path.to.field")
  108. console.error('Input value failed for schema validation! error details followed');
  109. console.error(errors[0]['message']);
  110. (singleCtorJsonValues_@uniqueCtorSubmitButtonId).push(editor.getValue());
  111. }
  112. else {
  113. // It's valid!
  114. (singleCtorJsonValues_@uniqueCtorSubmitButtonId).push(editor.getValue());
  115. }
  116. });
  117. console.info('Value generated for MetaParts FullTypeStr: @(partsDescriptor.FullTypeString + " PartsType: "+ @partsDescriptorGroup.GroupType + " PartsTypeString: " + @partsDescriptor.TypeString)')
  118. console.info(JSON.stringify(singleCtorJsonValues_@uniqueCtorSubmitButtonId));
  119. });
  120. </script>
  121. </div>
  122. </li>
  123. }
  124. </ul>
  125. </li>
  126. }
  127. </ul>
  128. </li>
  129. }
  130. </ul>
  131. </li>
  132. }
  133. </ul>
  134. </div>