本文整理汇总了C#中FubuMVC.Core.Registration.Routes.RouteDefinition.AddHttpMethodConstraint方法的典型用法代码示例。如果您正苦于以下问题:C# RouteDefinition.AddHttpMethodConstraint方法的具体用法?C# RouteDefinition.AddHttpMethodConstraint怎么用?C# RouteDefinition.AddHttpMethodConstraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FubuMVC.Core.Registration.Routes.RouteDefinition
的用法示例。
在下文中一共展示了RouteDefinition.AddHttpMethodConstraint方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: add_multiple_http_constraints
public void add_multiple_http_constraints()
{
var route = new RouteDefinition("something");
route.AddHttpMethodConstraint("get");
route.AddHttpMethodConstraint("POST");
route.GetHttpMethodConstraints().ShouldHaveTheSameElementsAs("GET", "POST");
}
示例2: Build
public IRouteDefinition Build(ActionCall call)
{
var className = call.HandlerType.Name.ToLower()
.Replace("endpoints", "")
.Replace("endpoint", "")
.Replace("controller", "");
RouteDefinition route = null;
if (RouteDefinition.VERBS.Any(x => x.EqualsIgnoreCase(call.Method.Name)))
{
route = new RouteDefinition(className);
route.AddHttpMethodConstraint(call.Method.Name.ToUpper());
}
else
{
route = new RouteDefinition("{0}/{1}".ToFormat(className, call.Method.Name.ToLowerInvariant()));
}
if (call.InputType() != null)
{
if (call.InputType().CanBeCastTo<ResourcePath>())
{
ResourcePath.AddResourcePathInputs(route);
}
else
{
AddBasicRouteInputs(call, route);
}
}
return route;
}
示例3: Configure
public void Configure(BehaviorGraph graph)
{
var route = new RouteDefinition("");
route.AddHttpMethodConstraint("GET");
var chain = new BehaviorChain { Route = route };
chain.AddToEnd(new RedirectNode());
graph.AddChain(chain);
graph.Services.AddService(this);
}
示例4: Build
public IRouteDefinition Build(ActionCall call)
{
Type viewModelType = call.HandlerType.GetGenericArguments()[0];
var route = new RouteDefinition(viewModelType.Name.Replace("ViewModel","").ToLower());
route.ApplyInputType(viewModelType);
route.AddHttpMethodConstraint("POST");
return route;
}
示例5: Build
public IRouteDefinition Build(ActionCall call)
{
// Later on we need to put in real plural naming.
string pattern = call.HandlerType.GetGenericArguments()[0].Name.Replace("ViewModel", "") + "es";
var route = new RouteDefinition(pattern.ToLower());
route.ApplyInputType(call.InputType());
route.AddHttpMethodConstraint("GET");
return route;
}
示例6: Configure
public void Configure(BehaviorGraph graph)
{
if (!graph.Behaviors.Any(x => x.Route != null && x.GetRoutePattern().IsEmpty()))
{
var action = ActionCall.For<DefaultHome>(x => x.GoToDiagnostics());
var continuer = new ContinuationNode();
var route = new RouteDefinition("");
route.AddHttpMethodConstraint("GET");
var chain = new BehaviorChain {Route = route};
chain.AddToEnd(action);
chain.AddToEnd(continuer);
graph.AddChain(chain);
}
}
示例7: Build
public IRouteDefinition Build(ActionCall call)
{
string pattern = call.HandlerType.GetGenericArguments()[0].Name.Replace("ViewModel", "");
var route = new RouteDefinition(pattern.ToLower());
route.Append("{Id}");
if (call.InputType().Name.StartsWith("Edit`"))
{
route.Append("edit");
}
else if (call.InputType().Name.StartsWith("Get`"))
{
route.Append("view");
}
route.ApplyInputType(call.InputType());
route.AddHttpMethodConstraint("GET");
return route;
}
示例8: create_route_with_http_constraints
public void create_route_with_http_constraints()
{
var route = new RouteDefinition("something");
route.AddHttpMethodConstraint("Get");
route.AddHttpMethodConstraint("POST");
route.ToRoute().Constraints.Single().Value.ShouldBeOfType<HttpMethodConstraint>()
.AllowedMethods.ShouldHaveTheSameElementsAs("GET", "POST");
}
示例9: responds_to_get_if_GET_is_explicitly_allowed
public void responds_to_get_if_GET_is_explicitly_allowed()
{
var route = new RouteDefinition("something");
route.AddHttpMethodConstraint("Get");
route.AddHttpMethodConstraint("POST");
route.RespondsToGet().ShouldBeTrue();
}
示例10: does_not_respond_to_get_if_http_methods_are_explicitly_defined_and_get_is_not_allowed
public void does_not_respond_to_get_if_http_methods_are_explicitly_defined_and_get_is_not_allowed()
{
var route = new RouteDefinition("something");
route.AddHttpMethodConstraint("POST");
route.RespondsToGet().ShouldBeFalse();
}