本文整理汇总了C#中IResourceManager.Match方法的典型用法代码示例。如果您正苦于以下问题:C# IResourceManager.Match方法的具体用法?C# IResourceManager.Match怎么用?C# IResourceManager.Match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IResourceManager
的用法示例。
在下文中一共展示了IResourceManager.Match方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildBranch
public RequestDelegate BuildBranch(IApplicationBuilder app, IEnumerable<IResourceStartup> resourceStartups, IEnumerable<IResource> resources, IResourceManager resourceManager)
{
var branchApp = app.New();
branchApp.Map($"/{_serverOptions.BasePath}", glimpseApp =>
{
// REGISTER: resource startups
foreach (var resourceStartup in resourceStartups)
{
var startupApp = glimpseApp.New();
var resourceBuilderStartup = new ResourceBuilder(startupApp, resourceManager);
resourceStartup.Configure(resourceBuilderStartup);
glimpseApp.Use(next =>
{
startupApp.Run(next);
var startupBranch = startupApp.Build();
return context =>
{
if (CanExecute(context, resourceStartup.Type))
{
return startupBranch(context);
}
return next(context);
};
});
}
// REGISTER: resources
var resourceBuilder = new ResourceBuilder(glimpseApp, resourceManager);
foreach (var resource in resources)
{
resourceBuilder.Run(resource.Name, resource.Parameters?.GenerateUriTemplate(), resource.Type, resource.Invoke);
}
glimpseApp.Run(async context =>
{
// RUN: resources
var result = resourceManager.Match(context);
if (result != null)
{
if (CanExecute(context, result.Type))
{
await result.Resource(context, result.Paramaters);
}
else
{
// TODO: Review, do we want a 401, 404 or continue users pipeline
context.Response.StatusCode = 401;
}
}
});
});
branchApp.Use(subNext => { return async ctx => await _next(ctx); });
return branchApp.Build();
}