当前位置: 首页 > news >正文

建筑公司名称大全做网站 seo

建筑公司名称大全,做网站 seo,常州免费网站建站模板,wordpress 安装百度编辑器在上篇文章中#xff0c;我为构建自定义端点可视化图奠定了基础#xff0c;正如我在第一篇文章中展示的那样。该图显示了端点路由的不同部分#xff1a;文字值#xff0c;参数#xff0c;动词约束和产生结果的端点#xff1a;在本文中#xff0c;我将展示如何通过创建一… 在上篇文章中我为构建自定义端点可视化图奠定了基础正如我在第一篇文章中展示的那样。该图显示了端点路由的不同部分文字值参数动词约束和产生结果的端点在本文中我将展示如何通过创建一个自定义的DfaGraphWriter来为自己的应用程序创建一个端点图。这篇文章使用了本系列前几篇文章中的技巧和类因此我强烈建议在继续之前先阅读这些技巧和类。相关阅读[译]使用DOT语言和GraphvizOnline来可视化你的ASP.NETCore3.0终结点01将终结点图添加到你的ASP.NET Core应用程序中使用ImpromptuInterface反射方便的创建自定义DfaGraphWriter为端点图添加配置我们首先要看的是如何配置最终端点图的外观。我们将为两种类型的节点和四种类型的边缘添加配置。边是文字边缘路线部分例如api和values中的文字匹配api/values/{id}。参数边缘路线的参数化部分例如{id}route中api/values/{id}。捕获所有边与“全部捕获”路由参数相对应的边例如{**slug}。策略边缘与URL以外的其他约束相对应的边缘。例如图中的基于HTTP谓词的边HTTP: GET。节点是匹配节点与端点匹配关联的节点因此将生成响应。默认节点不与端点匹配关联的节点。每个节点和边都可以具有任意数量的Graphviz属性来控制其显示。下面的GraphDisplayOptions显示了我在本文开始时用于生成图形的默认值public class GraphDisplayOptions {/// summary/// Additional display options for literal edges/// /summarypublic string LiteralEdge { get; set; } string.Empty;/// summary/// Additional display options for parameter edges/// /summarypublic string ParametersEdge { get; set; } arrowheaddiamond color\blue\;/// summary/// Additional display options for catchall parameter edges/// /summarypublic string CatchAllEdge { get; set; } arrowheadodot color\green\;/// summary/// Additional display options for policy edges/// /summarypublic string PolicyEdge { get; set; } color\red\ styledashed arrowheadopen;/// summary/// Additional display options for node which contains a match/// /summarypublic string MatchingNode { get; set; } shapebox stylefilled color\brown\ fontcolor\white\;/// summary/// Additional display options for node without matches/// /summarypublic string DefaultNode { get; set; } string.Empty; } 我们现在可以使用这个对象来控制显示并使用上一篇文章中所示的ImpromptuInterface“代理”技术来创建我们的自定义图形编写器。创建自定义的DfaGraphWriter我们的自定义图形编辑器巧妙地称为CustomDfaGraphWriter在很大程度上基于包含在ASP.NET Core中的DfaGraphWriter。该类的主体与原始类相同但有以下更改将GraphDisplayOptions注入类中以自定义显示。使用ImpromptuInterface库来处理内部DfaMatcherBuilder和DfaNode类如上一篇文章中所示。自定义WriteNode函数以使用我们的自定义样式。添加一个Visit函数来处理IDfaNode接口而不是在内部DfaNode类上使用Visit()方法。CustomDfaGraphWriter的全部代码如下所示重点是主Write()功能。我保持了与原始版本几乎相同的实现只是更新了我们必须更新的部分。public class CustomDfaGraphWriter {// Inject the GraphDisplayOptionsprivate readonly IServiceProvider _services;private readonly GraphDisplayOptions _options;public CustomDfaGraphWriter(IServiceProvider services, GraphDisplayOptions options){_services services;_options options;}public void Write(EndpointDataSource dataSource, TextWriter writer){// Use ImpromptuInterface to create the required dependencies as shown in previous postType matcherBuilder typeof(IEndpointSelectorPolicy).Assembly.GetType(Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder);// Build the list of endpoints used to build the graphvar rawBuilder _services.GetRequiredService(matcherBuilder);IDfaMatcherBuilder builder rawBuilder.ActLikeIDfaMatcherBuilder();// This is the same logic as the original graph writervar endpoints dataSource.Endpoints;for (var i 0; i endpoints.Count; i){if (endpoints[i] is RouteEndpoint endpoint (endpoint.Metadata.GetMetadataISuppressMatchingMetadata()?.SuppressMatching ?? false) false){builder.AddEndpoint(endpoint);}}// Build the raw tree from the registered routesvar rawTree builder.BuildDfaTree(includeLabel: true);IDfaNode tree rawTree.ActLikeIDfaNode();// Store a list of nodes that have already been visitedvar visited new DictionaryIDfaNode, int();// Build the graph by visiting each node, and calling WriteNode on eachwriter.WriteLine(digraph DFA {);Visit(tree, WriteNode);writer.WriteLine(});void WriteNode(IDfaNode node){/* Write the node to the TextWriter *//* Details shown later in this post*/}}static void Visit(IDfaNode node, ActionIDfaNode visitor){/* Recursively visit each node in the tree. *//* Details shown later in this post*/} } 为了简洁起见我在这里省略了Visit和 WriteNode函数但是我们会尽快对其进行研究。我们将从Visit函数开始因为该函数最接近原始函数。更新Visit函数以与IDfaNode一起使用正如我在上一篇文章中所讨论的创建自定义DfaGraphWriter的最大问题之一是它对内部类的使用。为了解决这个问题我使用ImpromptuInterface创建了包装原始对象的代理对象原始的Visit()方法是DfaNode类中的方法。它递归地访问端点树中的每个节点为每个节点调用一个提供的Action函数。由于DfaNode是internal我在CustomDfaGraphWriter中实现了一个静态的Visit来代替。我们的定制实现大体上与原始实现相同但是我们必须在“原始”DfaNodes和我们的IDfaNode代理之间进行一些有点困难的转换。更新后的方法如下所示。该方法接受两个参数即被检查的节点以及在每个参数上运行的Action。static void Visit(IDfaNode node, ActionIDfaNode visitor) {// Does the node of interest have any nodes connected by literal edges?if (node.Literals?.Values ! null){// node.Literals is actually a Dictionarystring, DfaNodeforeach (var dictValue in node.Literals.Values){// Create a proxy for the child DfaNode node and visit itIDfaNode value dictValue.ActLikeIDfaNode();Visit(value, visitor);}}// Does the node have a node connected by a parameter edge?// The reference check breaks any cycles in the graphif (node.Parameters ! null !ReferenceEquals(node, node.Parameters)){// Create a proxy for the DfaNode node and visit itIDfaNode parameters node.Parameters.ActLikeIDfaNode();Visit(parameters, visitor);}// Does the node have a node connected by a catch-all edge?// The refernece check breaks any cycles in the graphif (node.CatchAll ! null !ReferenceEquals(node, node.CatchAll)){// Create a proxy for the DfaNode node and visit itIDfaNode catchAll node.CatchAll.ActLikeIDfaNode();Visit(catchAll, visitor);}// Does the node have a node connected by a policy edges?if (node.PolicyEdges?.Values ! null){// node.PolicyEdges is actually a Dictionaryobject, DfaNodeforeach (var dictValue in node.PolicyEdges.Values){IDfaNode value dictValue.ActLikeIDfaNode();Visit(value, visitor);}}// Write the node using the provided Actionvisitor(node); } Visit函数使用post-order遍历因此在使用visitor函数编写节点之前它首先“深入”地遍历节点的子节点。这与原始DfaNode.Visit()功能相同。我们现在快到了。我们有一个类它构建端点节点树遍历树中的所有节点并为每个节点运行一个函数。剩下的就是定义访问者函数WriteNode()。定义自定义WriteNode函数我们终于到了最重要的部分控制了端点图的显示方式。到目前为止所有自定义和努力都是使我们能够自定义WriteNode功能。WriteNode()是一个局部函数它使用点图描述语言将一个节点连同任何连接的边一起写入TextWriter输出。我们的自定义WriteNode函数与原始函数几乎相同。有两个主要区别原始的图形编写器使用DfaNodes我们必须转换为使用IDfaNode代理。原始图形编写器对所有节点和边使用相同的样式。我们根据配置的GraphDisplayOptions定制节点和边的显示。由于WriteNode是一个局部函数它可以从封闭函数访问变量。这包括writer参数用于将图形写入输出和以前写入节点的已访问字典。下面显示了我们的方法已被大量注释的自定义版本WriteNode()。void WriteNode(IDfaNode node) {// add the node to the visited node dictionary if it isnt already// generate a zero-based integer label for the nodeif (!visited.TryGetValue(node, out var label)){label visited.Count;visited.Add(node, label);}// We can safely index into visited because this is a post-order traversal,// all of the children of this node are already in the dictionary.// If this node is linked to any nodes by a literal edgeif (node.Literals ! null){foreach (DictionaryEntry dictEntry in node.Literals){// Foreach linked node, get the label for the edge and the linked nodevar edgeLabel (string)dictEntry.Key;IDfaNode value dictEntry.Value.ActLikeIDfaNode();int nodeLabel visited[value];// Write an edge, including our custom styling for literal edgeswriter.WriteLine(${label} - {nodeLabel} [label\/{edgeLabel}\ {_options.LiteralEdge}]);}}// If this node is linked to a nodes by a parameter edgeif (node.Parameters ! null){IDfaNode parameters node.Parameters.ActLikeIDfaNode();int nodeLabel visited[catchAll];// Write an edge labelled as /* using our custom styling for parameter edgeswriter.WriteLine(${label} - {nodeLabel} [label\/**\ {_options.CatchAllEdge}]);}// If this node is linked to a catch-all edgeif (node.CatchAll ! null node.Parameters ! node.CatchAll){IDfaNode catchAll node.CatchAll.ActLikeIDfaNode();int nodeLabel visited[catchAll];// Write an edge labelled as /** using our custom styling for catch-all edgeswriter.WriteLine(${label} - {nodelLabel} [label\/**\ {_options.CatchAllEdge}]);}// If this node is linked to any Policy Edgesif (node.PolicyEdges ! null){foreach (DictionaryEntry dictEntry in node.PolicyEdges){// Foreach linked node, get the label for the edge and the linked nodevar edgeLabel (object)dictEntry.Key;IDfaNode value dictEntry.Value.ActLikeIDfaNode();int nodeLabel visited[value];// Write an edge, including our custom styling for policy edgeswriter.WriteLine(${label} - {nodeLabel} [label\{key}\ {_options.PolicyEdge}]);}}// Does this node have any associated matches, indicating it generates a response?var matchCount node?.Matches?.Count ?? 0;var extras matchCount 0 ? _options.MatchingNode // If we have matches, use the styling for response-generating nodes...: _options.DefaultNode; // ...otherwise use the default style// Write the node to the graph outputwriter.WriteLine(${label} [label\{node.Label}\ {extras}]); } 由于我们将节点从“叶”节点写回到树的根的方式因此跟踪这些交互的流程可能会有些混乱。例如如果我们看一下本文开头显示的基本应用程序的输出您会看到“叶子”端点都被首先写入healthz运行状况检查端点和终端匹配生成路径最长的端点digraph DFA {1 [label/healthz/ shapebox stylefilled colorbrown fontcolorwhite]2 [label/api/Values/{...}/ HTTP: GET shapebox stylefilled colorbrown fontcolorwhite]3 [label/api/Values/{...}/ HTTP: PUT shapebox stylefilled colorbrown fontcolorwhite]4 [label/api/Values/{...}/ HTTP: DELETE shapebox stylefilled colorbrown fontcolorwhite]5 [label/api/Values/{...}/ HTTP: * shapebox stylefilled colorbrown fontcolorwhite]6 - 2 [labelHTTP: GET colorred styledashed arrowheadopen]6 - 3 [labelHTTP: PUT colorred styledashed arrowheadopen]6 - 4 [labelHTTP: DELETE colorred styledashed arrowheadopen]6 - 5 [labelHTTP: * colorred styledashed arrowheadopen]6 [label/api/Values/{...}/]7 [label/api/Values/ HTTP: GET shapebox stylefilled colorbrown fontcolorwhite]8 [label/api/Values/ HTTP: POST shapebox stylefilled colorbrown fontcolorwhite]9 [label/api/Values/ HTTP: * shapebox stylefilled colorbrown fontcolorwhite]10 - 6 [label/* arrowheaddiamond colorblue]10 - 7 [labelHTTP: GET colorred styledashed arrowheadopen]10 - 8 [labelHTTP: POST colorred styledashed arrowheadopen]10 - 9 [labelHTTP: * colorred styledashed arrowheadopen]10 [label/api/Values/]11 - 10 [label/Values]11 [label/api/]12 - 1 [label/healthz]12 - 11 [label/api]12 [label/] } 即使首先将叶节点写入图形输出但Graphviz可视化工具通常会以叶节点在底部边缘朝下的方式绘制图形。您可以在https://dreampuf.github.io/GraphvizOnline/在线显示图形如果要更改图形的呈现方式可以自定义GraphDisplayOptions。如果使用我在上一篇文章中描述的“测试”方法则可以在生成图形时直接传递这些选项。如果使用的是“中间件”方法则可以改为使用IOptions系统进行GraphDisplayOptions注册并使用配置系统控制显示。摘要在这篇文章中我展示了如何创建自定义的DfaGraphWriter来控制如何生成应用程序的端点图。为了与internal内部类进行互操作我们使用了ImpromptuInterface如在上篇文章所示创建代理我们可以互动。然后我们必须编写一个自定义Visit()函数来使用IDfaNode代理。最后我们创建了一个自定义WriteNode函数该函数使用在GraphDisplayOptions对象中定义的自定义设置来显示不同类型的节点和边。往期精彩回顾【推荐】.NET Core开发实战视频课程 ★★★.NET Core实战项目之CMS 第一章 入门篇-开篇及总体规划【.NET Core微服务实战-统一身份认证】开篇及目录索引Redis基本使用及百亿数据量中的使用技巧分享附视频地址及观看指南.NET Core中的一个接口多种实现的依赖注入与动态选择看这篇就够了10个小技巧助您写出高性能的ASP.NET Core代码用abp vNext快速开发Quartz.NET定时任务管理界面在ASP.NET Core中创建基于Quartz.NET托管服务轻松实现作业调度现身说法实际业务出发分析百亿数据量下的多表查询优化关于C#异步编程你应该了解的几点建议C#异步编程看这篇就够了给我好看 您看此文用  · 秒转发只需1秒呦~ 好看你就点点我
http://www.zqtcl.cn/news/759745/

相关文章:

  • 网站建设备案和免备案的区别建网站视频教程
  • 网站推广话术wordpress主题没法用
  • 微信网站开发 全屏包头教育云平台网站建设
  • 诸城手机网站建设做竞价网站
  • 网站策划报告公司简介模板范文高大上
  • 做信息图的免费网站如何获取网站是哪个公司制作
  • 乐清建设网站哪家好seo一个月赚多少钱
  • 哈尔滨专业官网建站企业h5公众号开发
  • 商城网站建设精英wordpress实例配置
  • 国内网站开发语言模板兔自用主题WordPress
  • 天津营销网站建设公司哪家好市场营销平台
  • 上海企业响应式网站建设推荐网站建设类织梦模板
  • 洛阳最好的做网站的公司哪家好信誉好的邢台做网站
  • 织梦 旅游网站模板seo百家外链网站
  • 做网站提升公司形象摄影网站建设任务书
  • wordpress建站不好用wordpress共用用户多站点
  • 企业网站设计请示杭州做企业网站的公司
  • 苏宁易购网站建设的不足之处wordpress myisam
  • 互联网站建设维护是做什么的网站建设模板成功案例
  • 制作网站需要什么语言wordpress 免签约支付宝
  • 西安网站开发的未来发展易企网络网站建设
  • 贵州做网站怎么推广vs2012 做网站教程
  • 完全菜鸟七天学会建网站网络营销的四大基础理论
  • 东莞网站优化案例网站职业技术培训学校
  • 银川网站建设公司电话公司在百度做网站找谁
  • 交换链接适用于哪些网站网络规划与设计的目的
  • 网站做标签寺院网站模板
  • 高端h5网站柳州建站
  • 百度商桥网站郑州有做网站的公司没
  • 做专业网站济南品牌网站建设低价