public void AttemptToAttachViewToAction(ViewBag bag, ActionCall call, IConfigurationObserver observer) { foreach (var filter in _filters) { var viewTokens = filter.Apply(call, bag); var count = viewTokens.Count(); observer.RecordCallStatus(call, "View filter '{0}' found {1} view token{2}".ToFormat( filter.GetType().Name, count, (count != 1) ? "s" : "" )); if( count > 0 ) { viewTokens.Each(t => observer.RecordCallStatus(call, "Found view token: {0}".ToFormat(t))); } // if the filter returned more than one, consider it "failed", ignore it, and move on to the next if (count == 1) { var token = viewTokens.First(); observer.RecordCallStatus(call, "Selected view token: {0}".ToFormat(token)); call.AddToEnd(token.ToBehavioralNode()); break; } } }
public void AttemptToAttachViewToAction(ViewBag bag, ActionCall call, IConfigurationObserver observer) { foreach (var filter in _filters) { var viewTokens = filter.Apply(call, bag); var count = viewTokens.Count(); observer.RecordCallStatus(call, "View filter '{0}' found {1} view token{2}".ToFormat( filter.GetType().Name, count, (count != 1) ? "s" : "")); if (count > 0) { viewTokens.Each(t => observer.RecordCallStatus(call, "Found view token: {0}".ToFormat(t))); } // if the filter returned more than one, consider it "failed", ignore it, and move on to the next if (count != 1) { continue; } var token = viewTokens.First(); observer.RecordCallStatus(call, "Selected view token: {0}".ToFormat(token)); call.AddToEnd(token.ToBehavioralNode()); break; } }
public void Apply(BehaviorGraph graph, BehaviorChain chain) { // Don't override the route if it already exists if (chain.Route != null) { return; } // Don't override the route if the chain is a partial if (chain.IsPartialOnly) { return; } _observer = graph.Observer; ActionCall call = chain.Calls.FirstOrDefault(); if (call == null) { return; } IUrlPolicy policy = _policies.FirstOrDefault(x => x.Matches(call, _observer)) ?? _defaultUrlPolicy; _observer.RecordCallStatus(call, "First matching UrlPolicy (or default): {0}".ToFormat(policy.GetType().Name)); IRouteDefinition route = policy.Build(call); _constraintPolicy.Apply(call, route, _observer); _observer.RecordCallStatus(call, "Route definition determined by url policy: [{0}]".ToFormat(route.ToRoute().Url)); chain.Route = route; }
public bool Matches(ActionCall call, IConfigurationObserver log) { var result = call.InputType() == _inputType; if (result && _foundCallAlready) { throw new FubuException(1003, "Cannot make input type '{0}' the default route as there is more than one action that uses that input type. Either choose a input type that is used by only one action, or use the other overload of '{1}' to specify the actual action method that will be called by the default route.", _inputType.Name, ReflectionHelper.GetMethod<RouteConventionExpression>(r => r.HomeIs<object>()). Name ); } if (result) _foundCallAlready = true; if (result && log.IsRecording) { log.RecordCallStatus(call, "Action '{0}' is the default route since its input type is {1} which was specified in the configuration as the input model for the default route" .ToFormat(call.Method.Name, _inputType.Name)); } return result; }
public bool Matches(ActionCall call, IConfigurationObserver log) { var result = call.InputType() == _inputType; if (result && _foundCallAlready) { throw new FubuException(1003, "Cannot make input type '{0}' the default route as there is more than one action that uses that input type. Either choose a input type that is used by only one action, or use the other overload of '{1}' to specify the actual action method that will be called by the default route.", _inputType.Name, ReflectionHelper.GetMethod <RouteConventionExpression>(r => r.HomeIs <object>()).Name ); } if (result) { _foundCallAlready = true; } if (result && log.IsRecording) { log.RecordCallStatus(call, "Action '{0}' is the default route since its input type is {1} which was specified in the configuration as the input model for the default route" .ToFormat(call.Method.Name, _inputType.Name)); } return(result); }
public void Apply(ActionCall call, IRouteDefinition routeDefinition, IConfigurationObserver observer) { _httpMethodFilters.Where(x => x.Filter(call)).Each(filter => { observer.RecordCallStatus(call, "Adding route constraint {0} based on filter [{1}]".ToFormat(filter.Method, filter.Description)); routeDefinition.AddHttpMethodConstraint(filter.Method); }); }
public void Apply(ActionCall call, IRouteDefinition routeDefinition, IConfigurationObserver observer) { _httpMethodFilters.Where(x => x.Filter(call)).Each(filter => { observer.RecordCallStatus(call, "Adding route constraint {0} based on filter [{1}]".ToFormat(filter.Method, filter.Description)); routeDefinition.AddHttpMethodConstraint(filter.Method); }); }
public bool Matches(ActionCall call, IConfigurationObserver log) { if (!call.IsDiagnosticsEndpoint()) { return(false); } log.RecordCallStatus(call, "Matched on {0}".ToFormat(GetType().Name)); return(true); }
public bool Matches(ActionCall call, IConfigurationObserver log) { if(!call.HandlerType.Name.EndsWith(ENDPOINT)) { return false; } log.RecordCallStatus(call, "Matched on {0}".ToFormat(GetType().Name)); return true; }
public virtual bool Matches(ActionCall call, IConfigurationObserver log) { if (!IsHandlerCall(call)) { return(false); } log.RecordCallStatus(call, "Matched on {0}".ToFormat(GetType().Name)); return(true); }
public bool Matches(ActionCall call, IConfigurationObserver log) { if (!call.Method.HasAttribute <FubuDiagnosticsUrlAttribute>()) { return(false); } log.RecordCallStatus(call, "Matched on {0}".ToFormat(GetType().Name)); return(true); }
public bool Matches(ActionCall call, IConfigurationObserver log) { if(!call.Method.HasAttribute<FubuDiagnosticsUrlAttribute>()) { return false; } log.RecordCallStatus(call, "Matched on {0}".ToFormat(GetType().Name)); return true; }
public bool Matches(ActionCall call, IConfigurationObserver log) { if(!call.IsDiagnosticsEndpoint()) { return false; } log.RecordCallStatus(call, "Matched on {0}".ToFormat(GetType().Name)); return true; }
public bool Matches(ActionCall call, IConfigurationObserver log) { if ((!call.HandlerType.Name.ToLower().EndsWith(HANDLER.ToLower()) && !HandlerExpression.IsMatch(call.HandlerType.Name)) || call.Method.HasAttribute<UrlPatternAttribute>()) { return false; } log.RecordCallStatus(call, "Matched on {0}".ToFormat(GetType().Name)); return true; }
public bool Matches(ActionCall call, IConfigurationObserver log) { if (log.IsRecording) { log.RecordCallStatus(call, "This route will have /special in front of it"); } //Use FubuCore.TypeExtensions to aid the readability of your conventions //by using .CanBeCastTo<>() and other helper methods to match against types return call.HasOutput && call.OutputType().CanBeCastTo<string>(); }
public void Apply(ActionCall call, IRouteDefinition routeDefinition, IConfigurationObserver observer) { var matchingFilters = _httpMethodFilters.Where(x => x.Filter(call)); var httpMethods = matchingFilters.Select(x => x.Method).ToArray(); if (httpMethods.Length > 0) { routeDefinition.AddRouteConstraint(HTTP_METHOD_CONSTRAINT, new HttpMethodConstraint(httpMethods)); matchingFilters.Each(filter => observer.RecordCallStatus(call, "Adding route constraint {0} based on filter [{1}]".ToFormat(filter.Method, filter.Description))); } }
public void Apply(ActionCall call, IRouteDefinition routeDefinition, IConfigurationObserver observer) { var matchingFilters = _httpMethodFilters.Where(x => x.Filter(call)); var httpMethods = matchingFilters.Select(x => x.Method).ToArray(); if (httpMethods.Length > 0) { routeDefinition.AddRouteConstraint(HTTP_METHOD_CONSTRAINT, new HttpMethodConstraint(httpMethods)); matchingFilters.Each(filter => observer.RecordCallStatus(call, "Adding route constraint {0} based on filter [{1}]".ToFormat(filter.Method, filter.Description))); } }
public bool Matches(ActionCall call, IConfigurationObserver log) { if (!call.Method.HasAttribute<FubuPartialAttribute>()) return false; if (log.IsRecording) { log.RecordCallStatus(call, "Action '{0}' has the [{1}] defined. This action is only callable via a partial request from another action and cannot be navigated-to or routed-to from the client browser directly." .ToFormat(call.Method.Name, typeof (FubuPartialAttribute).Name)); } return true; }
public bool Matches(ActionCall call, IConfigurationObserver log) { var result = call.Method.HasAttribute<UrlPatternAttribute>(); if( result && log.IsRecording ) { log.RecordCallStatus(call, "Action '{0}' has the [{1}] defined. Using explicitly defined URL pattern." .ToFormat(call.Method.Name, typeof(UrlPatternAttribute).Name)); } return result; }
public static void Alter(IRouteDefinition route, ActionCall call, IConfigurationObserver observer) { var properties = call.HasInput ? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Keys : new string[0]; Alter(route, call.Method.Name, properties, text => observer.RecordCallStatus(call, text)); if (call.HasInput) { route.ApplyInputType(call.InputType()); } }
public bool Matches(ActionCall call, IConfigurationObserver log) { var result = call.Method.HasAttribute <UrlPatternAttribute>(); if (result && log.IsRecording) { log.RecordCallStatus(call, "Action '{0}' has the [{1}] defined. Using explicitly defined URL pattern." .ToFormat(call.Method.Name, typeof(UrlPatternAttribute).Name)); } return(result); }
public static void Alter(IRouteDefinition route, ActionCall call, IConfigurationObserver observer) { var properties = call.HasInput ? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Keys : new string[0]; Alter(route, call.Method.Name, properties, text => observer.RecordCallStatus(call, text)); if (call.HasInput) { route.ApplyInputType(call.InputType()); } }
private void attachMediaHandling(BehaviorChain chain, IConfigurationObserver observer) { var firstAction = chain.FirstCall(); if (firstAction == null) return; observer.RecordCallStatus(firstAction, "Meets criteria {0} for Conneg".ToFormat(_description)); var node = new ConnegNode(){ InputType = chain.InputType(), OutputType = chain.Calls.Where(x => x.HasOutput).Select(x => x.OutputType()).LastOrDefault() }; firstAction.AddBefore(node); }
public bool Matches(ActionCall call, IConfigurationObserver log) { if (!call.Method.HasAttribute <FubuPartialAttribute>()) { return(false); } if (log.IsRecording) { log.RecordCallStatus(call, "Action '{0}' has the [{1}] defined. This action is only callable via a partial request from another action and cannot be navigated-to or routed-to from the client browser directly." .ToFormat(call.Method.Name, typeof(FubuPartialAttribute).Name)); } return(true); }
private void attachMediaHandling(BehaviorChain chain, IConfigurationObserver observer) { var firstAction = chain.FirstCall(); if (firstAction == null) { return; } observer.RecordCallStatus(firstAction, "Meets criteria {0} for Conneg".ToFormat(_description)); var node = new ConnegNode() { InputType = chain.InputType(), OutputType = chain.Calls.Where(x => x.HasOutput).Select(x => x.OutputType()).LastOrDefault() }; firstAction.AddBefore(node); }
public void VisitBehavior(BehaviorChain chain) { if (!_filters.MatchesAll(chain)) { return; } var matchesDescriptions = _filters.GetDescriptionOfMatches(chain).Join(", "); if (matchesDescriptions == string.Empty) { matchesDescriptions = "(no filters defined)"; } chain.Calls.Each(call => _observer.RecordCallStatus(call, "Visiting: {0}. Matched on filters [{1}]".ToFormat (_reasonToVisit, matchesDescriptions))); _actions.Do(chain); }
private static void modifyChain(BehaviorChain chain, IConfigurationObserver observer) { chain.Calls.Each(c => observer.RecordCallStatus(c, "Wrapping with diagnostic tracer and behavior")); chain.ToArray().Each(node => node.AddBefore(Wrapper.For <BehaviorTracer>())); chain.Prepend(new Wrapper(typeof(DiagnosticBehavior))); }
private static void modifyChain(BehaviorChain chain, IConfigurationObserver observer) { chain.Calls.Each(c => observer.RecordCallStatus(c, "Wrapping with diagnostic tracer and behavior")); chain.ToArray().Each(node => node.AddBefore(Wrapper.For<BehaviorTracer>())); chain.Prepend(new Wrapper(typeof (DiagnosticBehavior))); }
public virtual bool Matches(ActionCall call, IConfigurationObserver log) { if (!IsHandlerCall(call)) { return false; } log.RecordCallStatus(call, "Matched on {0}".ToFormat(GetType().Name)); return true; }
public void Apply(BehaviorGraph graph, BehaviorChain chain) { // Don't override the route if it already exists if (chain.Route != null) { return; } // Don't override the route if the chain is a partial if (chain.IsPartialOnly) { return; } _observer = graph.Observer; ActionCall call = chain.Calls.FirstOrDefault(); if (call == null) return; IUrlPolicy policy = _policies.FirstOrDefault(x => x.Matches(call, _observer)) ?? _defaultUrlPolicy; _observer.RecordCallStatus(call, "First matching UrlPolicy (or default): {0}".ToFormat(policy.GetType().Name)); IRouteDefinition route = policy.Build(call); _constraintPolicy.Apply(call, route, _observer); _observer.RecordCallStatus(call, "Route definition determined by url policy: [{0}]".ToFormat(route.ToRoute().Url)); chain.Route = route; }
public bool Matches(ActionCall call, IConfigurationObserver log) { log.RecordCallStatus(call, "Matched on {0}".ToFormat(GetType().Name)); return true; }
public bool Matches(ActionCall call, IConfigurationObserver log) { log.RecordCallStatus(call, "Matched on {0}".ToFormat(GetType().Name)); return(true); }
private static void ModifyChain(CommandChain chain, IConfigurationObserver observer) { chain.Calls.Each(c => observer.RecordCallStatus(c, "Wrapping with invocation tracer")); chain.ToArray().Each(node => node.AddBefore(new Wrapper(typeof(InvocationTracer<>).MakeGenericType(chain.EntityType)))); }
public void Import(IConfigurationObserver import) { import.RecordedCalls().Each(call => import.GetLog(call) .Each(log => _importingObserver.RecordCallStatus(call, log))); }