本文整理汇总了C#中IRouter类的典型用法代码示例。如果您正苦于以下问题:C# IRouter类的具体用法?C# IRouter怎么用?C# IRouter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRouter类属于命名空间,在下文中一共展示了IRouter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EdgeApplication
// Consumers should use IoC or the Default UseEdge extension method to initialize this.
public EdgeApplication(
IFileSystem fileSystem,
string virtualRoot,
IRouter router,
ICompilationManager compiler,
IPageActivator activator,
IPageExecutor executor,
ITraceFactory tracer)
: this()
{
Requires.NotNull(fileSystem, "fileSystem");
Requires.NotNullOrEmpty(virtualRoot, "virtualRoot");
Requires.NotNull(router, "router");
Requires.NotNull(compiler, "compiler");
Requires.NotNull(activator, "activator");
Requires.NotNull(executor, "executor");
Requires.NotNull(tracer, "tracer");
FileSystem = fileSystem;
VirtualRoot = virtualRoot;
Router = router;
CompilationManager = compiler;
Executor = executor;
Activator = activator;
Tracer = tracer;
}
开发者ID:anurse,项目名称:Edge,代码行数:27,代码来源:EdgeApplication.cs
示例2: Add
/// <summary>
/// Add a new router.
/// </summary>
/// <param name="router">Router to add</param>
/// <exception cref="InvalidOperationException">Server have been started.</exception>
public void Add(IRouter router)
{
if (_isStarted)
throw new InvalidOperationException("Server have been started.");
_routers.Add(router);
}
开发者ID:xantilas,项目名称:ghalager-videobrowser-20120129,代码行数:12,代码来源:Server.cs
示例3: Match
//private string requiredSiteFolder;
//public SiteFolderRouteConstraint(string folderParam)
//{
// requiredSiteFolder = folderParam;
//}
public bool Match(
HttpContext httpContext,
IRouter route,
string parameterName,
IDictionary<string,object> values,
RouteDirection routeDirection)
{
string requestFolder = RequestSiteResolver.GetFirstFolderSegment(httpContext.Request.Path);
//return string.Equals(requiredSiteFolder, requestFolder, StringComparison.CurrentCultureIgnoreCase);
ISiteResolver siteResolver = httpContext.ApplicationServices.GetService<ISiteResolver>();
if(siteResolver != null)
{
try
{
// exceptions expected here until db install scripts have run or if db connection error
ISiteSettings site = siteResolver.Resolve();
if ((site != null) && (site.SiteFolderName == requestFolder)) { return true; }
}
catch
{
// do we need to log this?
}
}
return false;
}
开发者ID:ludev,项目名称:cloudscribe,代码行数:34,代码来源:SiteFolderRouteConstraint.cs
示例4: NancyRouterModule
public NancyRouterModule(IRouter router)
{
foreach (var route in router.Routes)
{
switch (route.Key.Method)
{
case Route.RouteMethod.Get:
Get[route.Key.Path] = x => (route.Value(CreateOwinContext()));
break;
case Route.RouteMethod.Delete:
Delete[route.Key.Path] = x => (route.Value(CreateOwinContext()));
break;
case Route.RouteMethod.Patch:
Patch[route.Key.Path] = x => (route.Value(CreateOwinContext()));
break;
case Route.RouteMethod.Post:
Post[route.Key.Path] = x => (route.Value(CreateOwinContext()));
break;
case Route.RouteMethod.Put:
Put[route.Key.Path] = x => (route.Value(CreateOwinContext()));
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
开发者ID:dcr25568,项目名称:mmbot,代码行数:26,代码来源:NancyRouterModule.cs
示例5: TemplateRoute
public TemplateRoute(
IRouter target,
string routeName,
string routeTemplate,
IDictionary<string, object> defaults,
IDictionary<string, object> constraints,
IDictionary<string, object> dataTokens,
IInlineConstraintResolver inlineConstraintResolver)
{
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}
_target = target;
_routeTemplate = routeTemplate ?? string.Empty;
Name = routeName;
_dataTokens = dataTokens == null ? RouteValueDictionary.Empty : new RouteValueDictionary(dataTokens);
// Data we parse from the template will be used to fill in the rest of the constraints or
// defaults. The parser will throw for invalid routes.
_parsedTemplate = TemplateParser.Parse(RouteTemplate);
_constraints = GetConstraints(inlineConstraintResolver, RouteTemplate, _parsedTemplate, constraints);
_defaults = GetDefaults(_parsedTemplate, defaults);
_matcher = new TemplateMatcher(_parsedTemplate, Defaults);
_binder = new TemplateBinder(_parsedTemplate, Defaults);
}
开发者ID:TerabyteX,项目名称:Routing,代码行数:30,代码来源:TemplateRoute.cs
示例6: TenantRoute
public TenantRoute(IRouter target,
string urlHost,
RequestDelegate pipeline) {
_target = target;
_urlHost = urlHost;
_pipeline = pipeline;
}
开发者ID:Giahim,项目名称:Brochard,代码行数:7,代码来源:TenantRoute.cs
示例7: AttributeRoute
public AttributeRoute(
IRouter target,
IActionDescriptorsCollectionProvider actionDescriptorsCollectionProvider,
IInlineConstraintResolver constraintResolver,
ILoggerFactory loggerFactory)
{
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}
if (actionDescriptorsCollectionProvider == null)
{
throw new ArgumentNullException(nameof(actionDescriptorsCollectionProvider));
}
if (constraintResolver == null)
{
throw new ArgumentNullException(nameof(constraintResolver));
}
if (loggerFactory == null)
{
throw new ArgumentNullException(nameof(loggerFactory));
}
_target = target;
_actionDescriptorsCollectionProvider = actionDescriptorsCollectionProvider;
_constraintResolver = constraintResolver;
_routeLogger = loggerFactory.CreateLogger<InnerAttributeRoute>();
_constraintLogger = loggerFactory.CreateLogger(typeof(RouteConstraintMatcher).FullName);
}
开发者ID:huoxudong125,项目名称:Mvc,代码行数:33,代码来源:AttributeRoute.cs
示例8: GuidedVNS
/// <summary>
/// Creates a new Guided Variable Neighbourhood Search solver.
/// </summary>
/// <param name="router"></param>
/// <param name="max"></param>
/// <param name="delivery_time"></param>
/// <param name="threshold_precentage"></param>
/// <param name="lambda"></param>
/// <param name="sigma"></param>
public GuidedVNS(IRouter<RouterPoint> router, Second max, Second delivery_time,
float threshold_precentage, float lambda, float sigma)
: base(max, delivery_time)
{
_threshold_percentage = threshold_precentage;
_lambda = lambda;
_sigma = sigma;
_intra_improvements = new List<IImprovement>();
//_intra_improvements.Add(
// new ArbitraryInsertionSolver());
_intra_improvements.Add(
new HillClimbing3OptSolver(true, true));
_inter_improvements = new List<IInterImprovement>();
_inter_improvements.Add(
new RelocateImprovement());
_inter_improvements.Add(
new ExchangeInterImprovement());
//_inter_improvements.Add(
// new TwoOptInterImprovement());
_inter_improvements.Add(
new RelocateExchangeInterImprovement());
_inter_improvements.Add(
new CrossExchangeInterImprovement());
}
开发者ID:jorik041,项目名称:osmsharp,代码行数:35,代码来源:GuidedVNS.cs
示例9: Match
public bool Match(HttpContext httpContext, IRouter route, string routeKey, IDictionary<string, object> values, RouteDirection routeDirection)
{
var context = httpContext.ApplicationServices.GetService<IPantherContext>();
var url = "/";
if (context == null)
return false;
//if (values.ContainsKey("culture") && !CheckCulture(values["culture"].ToString()))
// return false;
if(values.ContainsKey("url") && values["url"] != null)
url = values["url"].ToString();
var canHandle = context.CanHandleUrl(context.Path);
if (!canHandle)
return false;
if (!string.IsNullOrEmpty(context.Current.Controller))
values["controller"] = context.Current.Controller;
if (!string.IsNullOrEmpty(context.Current.Action))
values["action"] = context.Current.Action;
if (!string.IsNullOrEmpty(context.Current.Route))
context.Router.AddVirtualRouteValues(context.Current.Route, context.VirtualPath, values);
values["context"] = context;
return context.Current != null;
}
开发者ID:freemsly,项目名称:CMS,代码行数:32,代码来源:HostConstraint.cs
示例10: DefaultRouter
public DefaultRouter(IRouter defaultHandler, IRouteResolver routeResolver, IVirtualPathResolver virtualPathResolver, RequestCulture defaultRequestCulture)
{
if (defaultHandler == null)
{
throw new ArgumentNullException(nameof(defaultHandler));
}
if (routeResolver == null)
{
throw new ArgumentNullException(nameof(routeResolver));
}
if (virtualPathResolver == null)
{
throw new ArgumentNullException(nameof(virtualPathResolver));
}
if (defaultRequestCulture == null)
{
throw new ArgumentNullException(nameof(defaultRequestCulture));
}
_defaultHandler = defaultHandler;
_routeResolver = routeResolver;
_virtualPathResolver = virtualPathResolver;
_defaultRequestCulture = defaultRequestCulture;
}
开发者ID:marcuslindblom,项目名称:aspnet5,代码行数:27,代码来源:DefaultRouter.cs
示例11: CreateAttributeMegaRoute
/// <summary>
/// Creates an attribute route using the provided services and provided target router.
/// </summary>
/// <param name="target">The router to invoke when a route entry matches.</param>
/// <param name="services">The application services.</param>
/// <returns>An attribute route.</returns>
public static IRouter CreateAttributeMegaRoute(IRouter target, IServiceProvider services)
{
if (target == null)
{
throw new ArgumentNullException(nameof(target));
}
if (services == null)
{
throw new ArgumentNullException(nameof(services));
}
var actionDescriptorProvider = services.GetRequiredService<IActionDescriptorCollectionProvider>();
var inlineConstraintResolver = services.GetRequiredService<IInlineConstraintResolver>();
var pool = services.GetRequiredService<ObjectPool<UriBuildingContext>>();
var urlEncoder = services.GetRequiredService<UrlEncoder>();
var loggerFactory = services.GetRequiredService<ILoggerFactory>();
return new AttributeRoute(
target,
actionDescriptorProvider,
inlineConstraintResolver,
pool,
urlEncoder,
loggerFactory);
}
开发者ID:phinq19,项目名称:git_example,代码行数:32,代码来源:AttributeRouting.cs
示例12: VirtualPathData
/// <summary>
/// Initializes a new instance of the <see cref="VirtualPathData"/> class.
/// </summary>
/// <param name="router">The object that is used to generate the URL.</param>
/// <param name="virtualPath">The generated URL.</param>
/// <param name="dataTokens">The collection of custom values.</param>
public VirtualPathData(
IRouter router,
string virtualPath,
IDictionary<string, object> dataTokens)
: this(router, CreatePathString(virtualPath), dataTokens)
{
}
开发者ID:TerabyteX,项目名称:Routing,代码行数:13,代码来源:VirtualPathData.cs
示例13: AddPrefixRoute
public static IRouteBuilder AddPrefixRoute(this IRouteBuilder routeBuilder,
string prefix,
IRouter handler)
{
routeBuilder.Routes.Add(new PrefixRoute(handler, prefix));
return routeBuilder;
}
开发者ID:TerabyteX,项目名称:Routing,代码行数:7,代码来源:RouteBuilderExtensions.cs
示例14: RazorApplication
// Consumers should use IoC or the Default UseRazor extension method to initialize this.
public RazorApplication(
AppFunc nextApp,
IFileSystem fileSystem,
string virtualRoot,
IRouter router,
ICompilationManager compiler,
IPageActivator activator,
IPageExecutor executor,
ITraceFactory tracer)
: this(nextApp)
{
Requires.NotNull(fileSystem, "fileSystem");
Requires.NotNullOrEmpty(virtualRoot, "virtualRoot");
Requires.NotNull(router, "router");
Requires.NotNull(compiler, "compiler");
Requires.NotNull(activator, "activator");
Requires.NotNull(executor, "executor");
Requires.NotNull(tracer, "tracer");
FileSystem = fileSystem;
VirtualRoot = virtualRoot;
Router = router;
CompilationManager = compiler;
Executor = executor;
Activator = activator;
Tracer = tracer;
ITrace global = Tracer.ForApplication();
global.WriteLine("Started at '{0}'", VirtualRoot);
}
开发者ID:Kstal,项目名称:Microsoft.Owin,代码行数:31,代码来源:RazorApplication.cs
示例15: AddTenantRoute
public static IRouteBuilder AddTenantRoute(this IRouteBuilder routeBuilder,
string urlHost,
IRouter handler,
RequestDelegate pipeline) {
routeBuilder.Routes.Add(new TenantRoute(handler, urlHost, pipeline));
return routeBuilder;
}
开发者ID:jefth,项目名称:OrchardNoCMS,代码行数:7,代码来源:RouteBuilderExtensions.cs
示例16: InnerAttributeRoute
/// <summary>
/// Creates a new <see cref="InnerAttributeRoute"/>.
/// </summary>
/// <param name="next">The next router. Invoked when a route entry matches.</param>
/// <param name="entries">The set of route entries.</param>
public InnerAttributeRoute(
[NotNull] IRouter next,
[NotNull] IEnumerable<AttributeRouteMatchingEntry> matchingEntries,
[NotNull] IEnumerable<AttributeRouteLinkGenerationEntry> linkGenerationEntries,
[NotNull] ILogger logger,
[NotNull] ILogger constraintLogger,
int version)
{
_next = next;
_logger = logger;
_constraintLogger = constraintLogger;
Version = version;
// Order all the entries by order, then precedence, and then finally by template in order to provide
// a stable routing and link generation order for templates with same order and precedence.
// We use ordinal comparison for the templates because we only care about them being exactly equal and
// we don't want to make any equivalence between templates based on the culture of the machine.
_matchingRoutes = matchingEntries
.OrderBy(o => o.Order)
.ThenBy(e => e.Precedence)
.ThenBy(e => e.Route.RouteTemplate, StringComparer.Ordinal)
.Select(e => e.Route)
.ToArray();
var namedEntries = new Dictionary<string, AttributeRouteLinkGenerationEntry>(
StringComparer.OrdinalIgnoreCase);
foreach (var entry in linkGenerationEntries)
{
// Skip unnamed entries
if (entry.Name == null)
{
continue;
}
// We only need to keep one AttributeRouteLinkGenerationEntry per route template
// so in case two entries have the same name and the same template we only keep
// the first entry.
AttributeRouteLinkGenerationEntry namedEntry = null;
if (namedEntries.TryGetValue(entry.Name, out namedEntry) &&
!namedEntry.TemplateText.Equals(entry.TemplateText, StringComparison.OrdinalIgnoreCase))
{
throw new ArgumentException(
Resources.FormatAttributeRoute_DifferentLinkGenerationEntries_SameName(entry.Name),
"linkGenerationEntries");
}
else if (namedEntry == null)
{
namedEntries.Add(entry.Name, entry);
}
}
_namedEntries = namedEntries;
// The decision tree will take care of ordering for these entries.
_linkGenerationTree = new LinkGenerationDecisionTree(linkGenerationEntries.ToArray());
}
开发者ID:AndersBillLinden,项目名称:Mvc,代码行数:64,代码来源:InnerAttributeRoute.cs
示例17: Match
public bool Match(HttpContext httpContext,
IRouter route,
string routeKey,
IDictionary<string, object> values,
RouteDirection routeDirection)
{
throw new NotImplementedException();
}
开发者ID:nbilling,项目名称:Routing,代码行数:8,代码来源:RouteOptionsTests.cs
示例18: Server
public Server(IRouter router, int? threads = null, X509Certificate certificate = null)
{
Certificate = certificate;
Router = router;
// Prep the scheduler
Scheduler = new Core.Scheduler(threads ?? 1);
}
开发者ID:shz,项目名称:pointy,代码行数:8,代码来源:Server.cs
示例19: SingleQueueAndTopicPerMessageTypeRouter
public SingleQueueAndTopicPerMessageTypeRouter(IRouter fallbackRouter,
string singleCommandQueuePath = null,
string singleRequestQueuePath = null)
{
_fallbackRouter = fallbackRouter;
_singleCommandQueuePath = singleCommandQueuePath;
_singleRequestQueuePath = singleRequestQueuePath;
}
开发者ID:NimbusAPI,项目名称:Nimbus,代码行数:8,代码来源:SingleQueueAndTopicPerMessageTypeRouter.cs
示例20: Match
/// <inheritdoc />
public virtual bool Match(
HttpContext httpContext,
IRouter route,
string routeKey,
RouteValueDictionary values,
RouteDirection routeDirection)
{
if (httpContext == null)
{
throw new ArgumentNullException(nameof(httpContext));
}
if (route == null)
{
throw new ArgumentNullException(nameof(route));
}
if (routeKey == null)
{
throw new ArgumentNullException(nameof(routeKey));
}
if (values == null)
{
throw new ArgumentNullException(nameof(values));
}
switch (routeDirection)
{
case RouteDirection.IncomingRequest:
return AllowedMethods.Contains(httpContext.Request.Method, StringComparer.OrdinalIgnoreCase);
case RouteDirection.UrlGeneration:
// We need to see if the user specified the HTTP method explicitly. Consider these two routes:
//
// a) Route: template = "/{foo}", Constraints = { httpMethod = new HttpMethodRouteConstraint("GET") }
// b) Route: template = "/{foo}", Constraints = { httpMethod = new HttpMethodRouteConstraint("POST") }
//
// A user might know ahead of time that a URI he/she is generating might be used with a particular HTTP
// method. If a URI will be used for an HTTP POST but we match on (a) while generating the URI, then
// the HTTP GET-specific route will be used for URI generation, which might have undesired behavior.
//
// To prevent this, a user might call GetVirtualPath(..., { httpMethod = "POST" }) to
// signal that he is generating a URI that will be used for an HTTP POST, so he wants the URI
// generation to be performed by the (b) route instead of the (a) route, consistent with what would
// happen on incoming requests.
object obj;
if (!values.TryGetValue(routeKey, out obj))
{
return true;
}
return AllowedMethods.Contains(Convert.ToString(obj), StringComparer.OrdinalIgnoreCase);
default:
throw new ArgumentOutOfRangeException(nameof(routeDirection));
}
}
开发者ID:leloulight,项目名称:Routing,代码行数:59,代码来源:HttpMethodRouteConstraint.cs
注:本文中的IRouter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论