// 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; }
//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; }
public static IRouteBuilder AddTenantRoute(this IRouteBuilder routeBuilder, string urlHost, IRouter handler, RequestDelegate pipeline) { routeBuilder.Routes.Add(new TenantRoute(handler, urlHost, pipeline)); return routeBuilder; }
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(); } } }
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); }
/// <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()); }
public TenantRoute(IRouter target, string urlHost, RequestDelegate pipeline) { _target = target; _urlHost = urlHost; _pipeline = pipeline; }
/// <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); }
/// <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); }
/// <summary> /// Initializes a new instance of the <see cref="UrlHelper"/> class using the specified action context and /// action selector. /// </summary> /// <param name="contextAccessor">The <see cref="IScopedInstance{TContext}"/> to access the action context /// of the current request.</param> /// <param name="actionSelector">The <see cref="IActionSelector"/> to be used for verifying the correctness of /// supplied parameters for a route. /// </param> public UrlHelper(IScopedInstance<ActionContext> contextAccessor, IActionSelector actionSelector) { _httpContext = contextAccessor.Value.HttpContext; _router = contextAccessor.Value.RouteData.Routers[0]; _ambientValues = contextAccessor.Value.RouteData.Values; _actionSelector = actionSelector; }
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; }
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; }
/// <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) { }
public static IRouteBuilder AddPrefixRoute(this IRouteBuilder routeBuilder, string prefix, IRouter handler) { routeBuilder.Routes.Add(new PrefixRoute(handler, prefix)); return routeBuilder; }
// 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); }
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); }
/// <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()); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, IDictionary<string, object> values, RouteDirection routeDirection) { throw new NotImplementedException(); }
public Server(IRouter router, int? threads = null, X509Certificate certificate = null) { Certificate = certificate; Router = router; // Prep the scheduler Scheduler = new Core.Scheduler(threads ?? 1); }
public SingleQueueAndTopicPerMessageTypeRouter(IRouter fallbackRouter, string singleCommandQueuePath = null, string singleRequestQueuePath = null) { _fallbackRouter = fallbackRouter; _singleCommandQueuePath = singleCommandQueuePath; _singleRequestQueuePath = singleRequestQueuePath; }
/// <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)); } }
public SubdomainTemplateRoute(IRouter target, string routeName, string subdomainTemplate, string routeTemplate, IDictionary<string, object> defaults, IDictionary<string, object> constraints, IDictionary<string, object> dataTokens, IInlineConstraintResolver inlineConstraintResolver) { _innerRoute = new TemplateRoute(target, routeName, routeTemplate, defaults, constraints, dataTokens, inlineConstraintResolver); _subdomainTemplate = subdomainTemplate; _target = target; _matcher = new TemplateMatcher(TemplateParser.Parse(subdomainTemplate), Defaults); Name = routeName; }
public bool Match( HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { return !HasDotInLastSegment(values[_clientRouteTokenName] as string ?? string.Empty); }
public TenantRoute( ShellSettings shellSettings, IRouter target, RequestDelegate pipeline) { _target = target; _shellSettings = shellSettings; _pipeline = pipeline; }
/// <summary> /// Adds a bi-directional link brtween two routers and registers it on each router /// </summary> /// <param name="Source">A source router</param> /// <param name="Target">A target router</param> /// <param name="Cost">Path cost</param> public Link(IRouter Source, IRouter Target, int Cost) { this.source = Source; this.target = Target; this.cost = Cost; Source.AddLink(this); Target.AddLink(this.Reverse()); }
public TreeRouteBuilder(IRouter target, ILoggerFactory loggerFactory) { _target = target; _generatingEntries = new List<TreeRouteLinkGenerationEntry>(); _matchingEntries = new List<TreeRouteMatchingEntry>(); _logger = loggerFactory.CreateLogger<TreeRouter>(); _constraintLogger = loggerFactory.CreateLogger(typeof(RouteConstraintMatcher).FullName); }
/// <summary> /// Constructs the bus. /// </summary> public RebusBus(IWorkerFactory workerFactory, IRouter router, ITransport transport, IPipeline pipeline, IPipelineInvoker pipelineInvoker, ISubscriptionStorage subscriptionStorage) { _workerFactory = workerFactory; _router = router; _transport = transport; _pipeline = pipeline; _pipelineInvoker = pipelineInvoker; _subscriptionStorage = subscriptionStorage; }
public static bool Match(IReadOnlyDictionary<string, IRouteConstraint> constraints, IDictionary<string, object> routeValues, HttpContext httpContext, IRouter route, RouteDirection routeDirection, ILogger logger) { if (routeValues == null) { throw new ArgumentNullException(nameof(routeValues)); } if (httpContext == null) { throw new ArgumentNullException(nameof(httpContext)); } if (route == null) { throw new ArgumentNullException(nameof(route)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (constraints == null) { return true; } foreach (var kvp in constraints) { var constraint = kvp.Value; if (!constraint.Match(httpContext, route, kvp.Key, routeValues, routeDirection)) { if (routeDirection.Equals(RouteDirection.IncomingRequest)) { object routeValue; routeValues.TryGetValue(kvp.Key, out routeValue); logger.LogVerbose( "Route value '{RouteValue}' with key '{RouteKey}' did not match " + "the constraint '{RouteConstraint}'.", routeValue, kvp.Key, kvp.Value); } return false; } } return true; }
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv) { _router = new RouteCollection(); var builder = new ConfigurationBuilder() .SetBasePath(appEnv.ApplicationBasePath) .AddJsonFile("config.json") .AddEnvironmentVariables(); Configuration = builder.Build(); }
public TemplateRoute( IRouter target, string routeTemplate, IDictionary<string, object> defaults, IDictionary<string, object> constraints, IDictionary<string, object> dataTokens, IInlineConstraintResolver inlineConstraintResolver) : this(target, null, routeTemplate, defaults, constraints, dataTokens, inlineConstraintResolver) { }
private void LogDroppedMessage(IRouter router, NetworkEvent evt) { this.m_dropCounter.Inc(); this.m_logger.LogDebug("Routing cancelled by the {routerName}", router.Name); evt.Actions.Add(NetworkEventType.MessageDropped); }
public MvcMiddleware(IRouter router) { this.Router = router; }
/// <summary> /// Adds a new outbound route to the <see cref="TreeRouter"/>. /// </summary> /// <param name="handler">The <see cref="IRouter"/> for handling the link generation.</param> /// <param name="routeTemplate">The <see cref="RouteTemplate"/> of the route.</param> /// <param name="requiredLinkValues">The <see cref="RouteValueDictionary"/> containing the route values.</param> /// <param name="routeName">The route name.</param> /// <param name="order">The route order.</param> /// <returns>The <see cref="OutboundRouteEntry"/>.</returns> public OutboundRouteEntry MapOutbound( IRouter handler, RouteTemplate routeTemplate, RouteValueDictionary requiredLinkValues, string routeName, int order) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } if (routeTemplate == null) { throw new ArgumentNullException(nameof(routeTemplate)); } if (requiredLinkValues == null) { throw new ArgumentNullException(nameof(requiredLinkValues)); } var entry = new OutboundRouteEntry() { Handler = handler, Order = order, Precedence = RoutePrecedence.ComputeOutbound(routeTemplate), RequiredLinkValues = requiredLinkValues, RouteName = routeName, RouteTemplate = routeTemplate, }; var constraintBuilder = new RouteConstraintBuilder(_constraintResolver, routeTemplate.TemplateText); foreach (var parameter in routeTemplate.Parameters) { if (parameter.InlineConstraints != null) { if (parameter.IsOptional) { constraintBuilder.SetOptional(parameter.Name); } foreach (var constraint in parameter.InlineConstraints) { constraintBuilder.AddResolvedConstraint(parameter.Name, constraint.Constraint); } } } entry.Constraints = constraintBuilder.Build(); entry.Defaults = new RouteValueDictionary(); foreach (var parameter in entry.RouteTemplate.Parameters) { if (parameter.DefaultValue != null) { entry.Defaults.Add(parameter.Name, parameter.DefaultValue); } } OutboundEntries.Add(entry); return(entry); }
/// <summary> /// Ctor /// </summary> /// <param name="target">Target</param> /// <param name="routeName">Route name</param> /// <param name="routeTemplate">Route remplate</param> /// <param name="defaults">Defaults</param> /// <param name="constraints">Constraints</param> /// <param name="dataTokens">Data tokens</param> /// <param name="inlineConstraintResolver">Inline constraint resolver</param> public GenericPathRoute(IRouter target, string routeName, string routeTemplate, RouteValueDictionary defaults, IDictionary <string, object> constraints, RouteValueDictionary dataTokens, IInlineConstraintResolver inlineConstraintResolver) : base(target, routeName, routeTemplate, defaults, constraints, dataTokens, inlineConstraintResolver) { _target = target ?? throw new ArgumentNullException(nameof(target)); }
public ReverseProxyRouteBuilder(IApplicationBuilder applicationBuilder, IRouter defaultHandler) : base(applicationBuilder, defaultHandler) { }
private static IContextAccessor <ActionContext> CreateActionContext(HttpContext context, IRouter router) { var routeData = new RouteData(); routeData.Routers.Add(router); var actionContext = new ActionContext(context, routeData, new ActionDescriptor()); var contextAccessor = new Mock <IContextAccessor <ActionContext> >(); contextAccessor.SetupGet(c => c.Value) .Returns(actionContext); return(contextAccessor.Object); }
/// <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( IRouter next, IEnumerable <AttributeRouteMatchingEntry> matchingEntries, IEnumerable <AttributeRouteLinkGenerationEntry> linkGenerationEntries, ILogger logger, ILogger constraintLogger, int version) { if (next == null) { throw new ArgumentNullException(nameof(next)); } if (matchingEntries == null) { throw new ArgumentNullException(nameof(matchingEntries)); } if (linkGenerationEntries == null) { throw new ArgumentNullException(nameof(linkGenerationEntries)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (constraintLogger == null) { throw new ArgumentNullException(nameof(constraintLogger)); } _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. _matchingEntries = matchingEntries .OrderBy(o => o.Order) .ThenBy(e => e.Precedence) .ThenBy(e => e.RouteTemplate, StringComparer.Ordinal) .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), nameof(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()); }
public EngineRouterViewModel(IRouter router) { Router = router; Router.PropertyChanged += Router_PropertyChanged; }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { return(true); }
private VirtualPathData GetVirtualPath(IRouter odataRoute, HttpRequest request, IDictionary <string, object> values) { VirtualPathContext context = new VirtualPathContext(request.HttpContext, null, new RouteValueDictionary(values)); return(odataRoute.GetVirtualPath(context)); }
public LegacyRoute(IServiceProvider services, params string[] targetUrls) { this.urls = targetUrls; mvcRoute = services.GetRequiredService <MvcRouteHandler>(); }
public DD4TMiddleWare(RequestDelegate next, IRouter router) { _next = next; _router = router; }
public AppRouter(IRouter defaultRouter) { _defaultRouter = defaultRouter; _dynamicRouteProvider = DependencyResolver.Resolve <IDynamicRouteProvider>(); }
public GenericRule(IRouter target) { this.target = target; }
public UrlSlugRoute(IRouter target) { _target = target; }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { return(httpContext.Request.Path.Value?.ToLower().Contains("/.php") == true); }
public static BusBuilderConfiguration WithRouter(this BusBuilderConfiguration configuration, IRouter router) { configuration.Router = router; return(configuration); }
public Runner(IRouter @switch, string name) { this.@switch = @switch; Name = name; }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { throw new System.NotImplementedException(); }
private static IActionContextAccessor CreateActionContext(HttpContext context, IRouter router) { var routeData = new RouteData(); routeData.Routers.Add(router); var actionContext = new ActionContext(context, routeData, new ActionDescriptor()); return(new ActionContextAccessor() { ActionContext = actionContext }); }
public IRouter Import(IRouter router) { AddRangeToGlobalStack(router.RoutingTable); return(this); }
public RfqDetailsViewModel(IRouter <Model.Entities.RfqScreen> router) { _router = router; }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { return(Days.Contains(values[routeKey]?.ToString().ToLowerInvariant())); }
public BundleHandlerTests() { _router = Substitute.For <IRouter>(); _fhirRequestContext = new DefaultFhirRequestContext { BaseUri = new Uri("https://localhost/"), CorrelationId = Guid.NewGuid().ToString(), ResponseHeaders = new HeaderDictionary(), }; var fhirRequestContextAccessor = Substitute.For <RequestContextAccessor <IFhirRequestContext> >(); fhirRequestContextAccessor.RequestContext.Returns(_fhirRequestContext); IHttpContextAccessor httpContextAccessor = Substitute.For <IHttpContextAccessor>(); var fhirJsonSerializer = new FhirJsonSerializer(); var fhirJsonParser = new FhirJsonParser(); ISearchService searchService = Substitute.For <ISearchService>(); var resourceReferenceResolver = new ResourceReferenceResolver(searchService, new QueryStringParser()); var transactionBundleValidator = new TransactionBundleValidator(resourceReferenceResolver); var bundleHttpContextAccessor = new BundleHttpContextAccessor(); IFeatureCollection featureCollection = CreateFeatureCollection(); var httpContext = new DefaultHttpContext(featureCollection) { Request = { Scheme = "https", Host = new HostString("localhost"), PathBase = new PathString("/"), }, }; httpContextAccessor.HttpContext.Returns(httpContext); var transactionHandler = Substitute.For <ITransactionHandler>(); var resourceIdProvider = new ResourceIdProvider(); IAuditEventTypeMapping auditEventTypeMapping = Substitute.For <IAuditEventTypeMapping>(); _bundleConfiguration = new BundleConfiguration(); var bundleOptions = Substitute.For <IOptions <BundleConfiguration> >(); bundleOptions.Value.Returns(_bundleConfiguration); _mediator = Substitute.For <IMediator>(); _bundleHandler = new BundleHandler( httpContextAccessor, fhirRequestContextAccessor, fhirJsonSerializer, fhirJsonParser, transactionHandler, bundleHttpContextAccessor, resourceIdProvider, transactionBundleValidator, resourceReferenceResolver, auditEventTypeMapping, bundleOptions, DisabledFhirAuthorizationService.Instance, _mediator, NullLogger <BundleHandler> .Instance); }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { return(IsTokenValid(values["token"].ToString())); }
public AppTemplateRoute(IRouter target, string routeTemplate, IInlineConstraintResolver inlineConstraintResolver) : base(target, routeTemplate, inlineConstraintResolver: inlineConstraintResolver) { }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { var value = values[routeKey] as string; return(!Path.HasExtension(value)); }
public PageSlugRoute(IRouter router) { _router = router; }
public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection) { return(values[routeKey] != null && values[routeKey].ToString().Length == 2); }
/// <summary> /// Workarround use of private constructor to add reverse link - preventing stack overflow /// </summary> /// <param name="Source">Source Router</param> /// <param name="Target">Target Router</param> /// <param name="Cost">Link Cost</param> /// <param name="Reverse">Used purely for overloading</param> private Link(IRouter Source, IRouter Target, int Cost, bool Reverse) { this.source = Source; this.target = Target; this.cost = Cost; }