public ContainerBindingModel GetContainer(RouteDescriptor route) { return(new ContainerBindingModel { Url = route.Url }); }
public void Should_get_parameter_constraints() { var template = "fark/{param1:range(4, 8)}/{param2}/farker/" + "{param3:alpha}/{param4:int:range(5, 10)}"; var constraints = new RouteDescriptor(null, template, null, null, null, null) .GetRouteConstraints(new DefaultInlineConstraintResolver()); constraints.Count.ShouldEqual(3); var range = constraints["param1"] as RangeRouteConstraint; range.ShouldNotBeNull(); range.Min.ShouldEqual(4); range.Max.ShouldEqual(8); var alpha = constraints["param3"] as AlphaRouteConstraint; alpha.ShouldNotBeNull(); var composite = constraints["param4"] as CompoundRouteConstraint; composite.ShouldNotBeNull(); var @int = composite.Constraints.First() as IntRouteConstraint; @int.ShouldNotBeNull(); range = composite.Constraints.Skip(1).First() as RangeRouteConstraint; range.ShouldNotBeNull(); range.Min.ShouldEqual(5); range.Max.ShouldEqual(10); }
public RegistrationLoggingBehavior( IContainer container, IBehaviorChain behaviorChainChain, Logger logger, HttpRequestMessage requestMessage, HttpResponseMessage responseMessage, HttpResponseHeaders responseHeaders, HttpConfiguration httpConfiguration, HttpRequestContext httpRequestContext, ActionDescriptor actionDescriptor, ActionMethod actionMethod, RouteDescriptor routeDescriptor, RequestCancellation requestCancellation, UrlParameters urlParameters, QuerystringParameters querystringParameters, SomeType someInstance) { BehaviorChain = behaviorChainChain; logger.Write(container); logger.Write(requestMessage); logger.Write(responseMessage); logger.Write(responseHeaders); logger.Write(actionMethod); logger.Write(actionDescriptor); logger.Write(routeDescriptor); logger.Write(httpRequestContext); logger.Write(httpConfiguration); logger.Write(requestCancellation); logger.Write(urlParameters); logger.Write(querystringParameters); logger.Write(someInstance); }
public static List <Type> ThatApplyTo(this PluginDefinitions <IBehavior, BehaviorContext> behaviors, ActionSourceContext context, ActionMethod actionMethod, RouteDescriptor routeDescriptor) { return(behaviors.ThatApplyTo(new BehaviorContext(context.Configuration, context .HttpConfiguration, actionMethod, routeDescriptor)) .Select(x => x.Type).ToList()); }
protected BodyWriterBase(ActionMethod actionMethod, RouteDescriptor routeDescriptor, HttpResponseMessage responseMessage) { _routeDescriptor = routeDescriptor; _responseMessage = responseMessage; _actionMethod = actionMethod; }
public ActionDescriptor(ActionMethod action, RouteDescriptor route, TypeDescriptor[] behaviors = null) { Action = action; Route = route; Behaviors = behaviors ?? new TypeDescriptor[] {}; Registry = new Registry(); }
public StreamWriter(Configuration configuration, ActionMethod actionMethod, RouteDescriptor routeDescriptor, HttpResponseMessage responseMessage) : base(actionMethod, routeDescriptor, responseMessage) { _configuration = configuration; }
public JsonBinder(RouteDescriptor routeDescriptor, ArgumentBinder argumentBinder, HttpRequestMessage requestMessage) { _argumentBinder = argumentBinder; _routeDescriptor = routeDescriptor; _requestMessage = requestMessage; }
public QuerystringBinder(RouteDescriptor routeDescriptor, ArgumentBinder argumentBinder, QuerystringParameters querystringParameters) { _argumentBinder = argumentBinder; _routeDescriptor = routeDescriptor; _querystringParameters = querystringParameters; }
public ContainerBinder( Configuration configuration, RouteDescriptor routeDescriptor, IContainer container) { _configuration = configuration; _container = container; _routeDescriptor = routeDescriptor; }
public UrlParameterBinder( RouteDescriptor routeDescriptor, ArgumentBinder argumentBinder, UrlParameters urlParameters) { _argumentBinder = argumentBinder; _routeDescriptor = routeDescriptor; _urlParameters = urlParameters; }
public ActionConfigurationContext(Configuration configuration, HttpConfiguration httpConfiguration, ActionMethod actionMethodMethod, RouteDescriptor routeDescriptorDescriptor) { Configuration = configuration; HttpConfiguration = httpConfiguration; ActionMethod = actionMethodMethod; RouteDescriptor = routeDescriptorDescriptor; }
public HeaderBinder(Configuration configuration, RouteDescriptor routeDescriptor, ArgumentBinder argumentBinder, HttpRequestMessage requestMessage) { _argumentBinder = argumentBinder; _routeDescriptor = routeDescriptor; _configuration = configuration; _requestMessage = requestMessage; }
public RequestPropertiesBinder(Configuration configuration, RouteDescriptor routeDescriptor, ArgumentBinder argumentBinder, IRequestPropertiesProvider requestProperties) { _argumentBinder = argumentBinder; _requestProperties = requestProperties; _routeDescriptor = routeDescriptor; _configuration = configuration; }
public ValueMapperConfigurationContext(Configuration configuration, HttpConfiguration httpConfiguration, ActionMethod actionMethod, RouteDescriptor routeDescriptor, ActionParameter parameter, object[] values) : base(parameter, values) { Configuration = configuration; HttpConfiguration = httpConfiguration; Action = actionMethod; Route = routeDescriptor; }
public static List <Type> ThatApplyTo(this ConditionalPlugins <IBehavior, ActionConfigurationContext> behaviors, ActionMethod actionMethod, RouteDescriptor routeDescriptor, Configuration configuration, HttpConfiguration httpConfiguration) { var context = new ActionConfigurationContext(configuration, httpConfiguration, actionMethod, routeDescriptor); return(behaviors.ThatApplyTo(context) .Select(x => x.Type).ToList()); }
/// <summary> /// 映射一个Rabbit服务路由。 /// </summary> /// <param name="routes">应用程序的路由的集合。</param> /// <param name="name">要映射的路由的名称。</param> /// <param name="priority">优先级。</param> /// <param name="routePrefix">路由前缀。</param> /// <param name="serviceType">服务类型。</param> /// <returns>对映射路由的引用。</returns> public static RouteDescriptor MapRabbitServiceRoute(this ICollection <RouteDescriptor> routes, string name, int priority, string routePrefix, Type serviceType) { var route = new RouteDescriptor { Name = name, Priority = priority, Route = new ServiceRoute(routePrefix, new RabbitServiceHostFactory(), serviceType) }; routes.Add(route); return(route); }
public ParameterBinder(Configuration configuration, HttpConfiguration httpConfiguration, ActionMethod actionMethod, RouteDescriptor routeDescriptor, IEnumerable <IValueMapper> mappers) { _configuration = configuration; _httpConfiguration = httpConfiguration; _mappers = mappers; _actionMethod = actionMethod; _routeDescriptor = routeDescriptor; }
public TestRequestContext(ActionMethod actionMethod = null, RouteDescriptor route = null, TypeDescriptor[] behaviors = null, IDictionary <string, string> urlParameters = null, ILookup <string, string> querystringParameters = null, HttpRequestMessage requestMessage = null, HttpConfiguration httpConfiguration = null, CancellationToken cancellationToken = new CancellationToken()) : base(actionMethod, route, behaviors, urlParameters, querystringParameters, requestMessage, httpConfiguration, cancellationToken) { }
protected virtual RouteBase ProcessRoute(RouteConfigurationElement element) { Type handlerType = DetermineHandlerType(element); ValueDictionary defaults = ProcessDefaults(element.Defaults); ValueDictionary tokens = ProcessTokens(element.Tokens); IEnumerable <IRouteConstraint> constraints = ProcessConstraints(element.Constraints); RouteDescriptor descriptor = new RouteDescriptor( element.Url, element.Type, element.Attributes, handlerType); return(CreateRoute(descriptor, defaults, tokens, constraints)); }
public ActionDescriptor CreateDescriptor(ActionMethod actionMethod, RouteDescriptor routeDescriptor) { var actionConfigurationContext = new ActionConfigurationContext( _configuration, _httpConfiguration, actionMethod, routeDescriptor); return(new ActionDescriptor(actionMethod, routeDescriptor, _configuration.Authenticators.CloneAllThatApplyTo(actionConfigurationContext), _configuration.RequestBinders.CloneAllThatApplyTo(actionConfigurationContext), _configuration.RequestReaders.CloneAllThatApplyTo(actionConfigurationContext), _configuration.ResponseWriters.CloneAllThatApplyTo(actionConfigurationContext), _configuration.ResponseStatus.CloneAllThatApplyTo(actionConfigurationContext), _configuration.Behaviors.CloneAllThatApplyTo(actionConfigurationContext), _typeCache)); }
public static MapResult Map(this IEnumerable <IValueMapper> mappers, ActionMethod actionMethod, RouteDescriptor route, ActionParameter parameter, object[] values, Configuration configuration, HttpConfiguration httpConfiguration) { var mapperContext = new ValueMapperContext(parameter, values); var mapperConfigurationcontext = new ValueMapperConfigurationContext( configuration, httpConfiguration, actionMethod, route, parameter, values); var mapper = configuration.ValueMappers .FirstThatAppliesToOrDefault(mappers, mapperConfigurationcontext, mapperContext); return(mapper == null ? MapResult.NoMapper() : mapper.Map(mapperContext)); }
public RequestContext(ActionMethod actionMethod, RouteDescriptor route, TypeDescriptor[] behaviors, IDictionary <string, string> urlParameters, ILookup <string, string> querystringParameters, HttpRequestMessage requestMessage, HttpConfiguration httpConfiguration, CancellationToken cancellationToken) { Action = actionMethod; Route = route; Behaviors = behaviors; UrlParameters = urlParameters; QuerystringParameters = querystringParameters; RequestMessage = requestMessage; HttpConfiguration = httpConfiguration; CancellationToken = cancellationToken; }
private RouteBase CreateRoute(RouteDescriptor descriptor, IValueSet defaults, IValueSet tokens, IEnumerable <IRouteConstraint> constraints) { RouteFactory factory = GetRouteFactory(descriptor.Type); Route route = factory(descriptor); route.Defaults.Merge(defaults); route.Tokens.Merge(tokens); route.SecureConnection = descriptor.Attributes .GetValue <SecureConnectionOption>("secure"); foreach (IRouteConstraint constraint in constraints) { route.Constraints.Add(constraint); } return(route); }
public void GetRoutes(ICollection <RouteDescriptor> routes) { var routeDescriptor = new RouteDescriptor { Route = new Route( "Admin/Layouts/{controller}/{action}/{id}", new RouteValueDictionary { { "area", "Orchard.Layouts" }, { "id", UrlParameter.Optional } }, new RouteValueDictionary(), new RouteValueDictionary() { { "area", "Orchard.Layouts" } }, new MvcRouteHandler()) }; routes.Add(routeDescriptor); }
public void GetRoutes(ICollection <RouteDescriptor> routes) { var routeDescriptor = new RouteDescriptor { Priority = 5, Route = new Route( "Tags/{tagName}", new RouteValueDictionary { { "area", "Orchard.Tags" }, { "controller", "Home" }, { "action", "Search" } }, new RouteValueDictionary(), new RouteValueDictionary { { "area", "Orchard.Tags" } }, new MvcRouteHandler()) }; routes.Add(routeDescriptor); }
public void GetRoutes(ICollection <RouteDescriptor> routes) { var routeDescriptor = new RouteDescriptor { Priority = 5, Route = new Route( "Recipes/Status/{executionId}", new RouteValueDictionary { { "area", "Orchard.Recipes" }, { "controller", "Recipes" }, { "action", "RecipeExecutionStatus" } }, new RouteValueDictionary(), new RouteValueDictionary { { "area", "Orchard.Recipes" } }, new MvcRouteHandler()) }; routes.Add(routeDescriptor); }
public void GetRoutes(ICollection <RouteDescriptor> routes) { var routeDescriptor = new RouteDescriptor { Priority = -5, Route = new Route( "Admin", new RouteValueDictionary { { "area", "Dashboard" }, { "controller", "admin" }, { "action", "index" } }, new RouteValueDictionary(), new RouteValueDictionary { { "area", "Dashboard" } }, new MvcRouteHandler()) }; routes.Add(routeDescriptor); }
public void GetRoutes(ICollection <RouteDescriptor> routes) { var routeDescriptor = new RouteDescriptor { Priority = -5, Route = new Route( "rss", new RouteValueDictionary { { "area", "Feeds" }, { "controller", "Feed" }, { "action", "Index" }, { "format", "rss" }, }, new RouteValueDictionary(), new RouteValueDictionary { { "area", "Feeds" } }, new MvcRouteHandler()) }; routes.Add(routeDescriptor); }
public void GetRoutes(ICollection <RouteDescriptor> routes) { var routeDescriptor = new RouteDescriptor { Priority = -9999, Route = new Route( "{*path}", new RouteValueDictionary { { "area", "Common" }, { "controller", "Error" }, { "action", "NotFound" } }, new RouteValueDictionary { }, new RouteValueDictionary { { "area", "Common" } }, new MvcRouteHandler()) }; routes.Add(routeDescriptor); }
private RouteBase CreateRoute(RouteDescriptor descriptor, IValueSet defaults, IValueSet tokens, IEnumerable<IRouteConstraint> constraints) { RouteFactory factory = GetRouteFactory(descriptor.Type); Route route = factory(descriptor); route.Defaults.Merge(defaults); route.Tokens.Merge(tokens); route.SecureConnection = descriptor.Attributes .GetValue<SecureConnectionOption>("secure"); foreach (IRouteConstraint constraint in constraints) route.Constraints.Add(constraint); return route; }
protected virtual RouteBase ProcessRoute(RouteConfigurationElement element) { Type handlerType = DetermineHandlerType(element); ValueDictionary defaults = ProcessDefaults(element.Defaults); ValueDictionary tokens = ProcessTokens(element.Tokens); IEnumerable<IRouteConstraint> constraints = ProcessConstraints(element.Constraints); RouteDescriptor descriptor = new RouteDescriptor( element.Url, element.Type, element.Attributes, handlerType); return CreateRoute(descriptor, defaults, tokens, constraints); }