本文整理汇总了C#中ActionCall.ToRouteDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# ActionCall.ToRouteDefinition方法的具体用法?C# ActionCall.ToRouteDefinition怎么用?C# ActionCall.ToRouteDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionCall
的用法示例。
在下文中一共展示了ActionCall.ToRouteDefinition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public IRouteDefinition Build(ActionCall call)
{
var entityType = GetGenericParameter(call.HandlerType);
var pluralName = GetPluralName(entityType);
if (call.Method.Name == "New")
{
var routeDefinition = call.ToRouteDefinition();
routeDefinition.Append("api");
routeDefinition.Append(pluralName);
routeDefinition.Append("new");
routeDefinition.AddHttpMethodConstraint("GET");
return routeDefinition;
}
else if (call.Method.Name == "List")
{
var routeDefinition = call.ToRouteDefinition();
routeDefinition.Append("api");
routeDefinition.Append(pluralName);
routeDefinition.AddHttpMethodConstraint("GET");
return routeDefinition;
}
else if (call.Method.Name == "Add")
{
var routeDefinition = call.ToRouteDefinition();
routeDefinition.Append("api");
routeDefinition.Append(pluralName);
routeDefinition.AddHttpMethodConstraint("POST");
return routeDefinition;
}
else if (call.Method.Name == "Get")
{
var routeDefinition = call.ToRouteDefinition();
routeDefinition.Append("api");
routeDefinition.Append(pluralName);
routeDefinition.Input.AddRouteInput(new RouteParameter(new SingleProperty(call.InputType().GetProperty("Id"))), true);
routeDefinition.AddHttpMethodConstraint("GET");
return routeDefinition;
}
else if (call.Method.Name == "Update")
{
var routeDefinition = call.ToRouteDefinition();
routeDefinition.Append("api");
routeDefinition.Append(pluralName);
routeDefinition.Input.AddRouteInput(new RouteParameter(new SingleProperty(call.InputType().GetProperty("Id"))), true);
routeDefinition.AddHttpMethodConstraint("POST");
return routeDefinition;
}
throw new InvalidOperationException("Unknown method: " + call.Method.Name);
}
示例2: Build
public IRouteDefinition Build(ActionCall call)
{
var routeDefinition = call.ToRouteDefinition();
var strippedNamespace = call
.HandlerType
.Namespace
.Replace(typeof (EndpointMarker).Namespace + ".", string.Empty);
if (strippedNamespace != call.HandlerType.Namespace)
{
if (!strippedNamespace.Contains("."))
{
routeDefinition.Append(BreakUpCamelCaseWithHypen(strippedNamespace));
}
else
{
var patternParts = strippedNamespace.Split(new[] { "." }, StringSplitOptions.None);
foreach (var patternPart in patternParts)
{
routeDefinition.Append(BreakUpCamelCaseWithHypen(patternPart.Trim()));
}
}
}
routeDefinition.Append(BreakUpCamelCaseWithHypen(call.HandlerType.Name.Replace(ENDPOINT, string.Empty)));
routeDefinition.ApplyRouteInputAttributes(call);
routeDefinition.ApplyQueryStringAttributes(call);
return routeDefinition;
}
示例3: Build
public IRouteDefinition Build(ActionCall call)
{
var routeDefinition = call.ToRouteDefinition();
routeDefinition.Append(call.HandlerType.Namespace.Replace(GetType().Namespace + ".", string.Empty).ToLower());
routeDefinition.Append(call.HandlerType.Name.Replace("Handler", string.Empty).ToLower());
return routeDefinition;
}
示例4: Build
public IRouteDefinition Build(ActionCall call)
{
var routeDefinition = call.ToRouteDefinition();
routeDefinition.Append(call.HandlerType.Namespace.Substring(call.HandlerType.Namespace.LastIndexOf('.') + 1));
routeDefinition.Append(call.HandlerType.Name.Substring(0, call.HandlerType.Name.LastIndexOf("Projection")));
return routeDefinition;
}
示例5: Build
public IRouteDefinition Build(ActionCall call)
{
IRouteDefinition route = call.ToRouteDefinition();
if (!IgnoreControllerNamespaceEntirely)
{
addNamespace(route, call);
}
if (!IgnoreControllerNamesEntirely)
addClassName(route, call);
addMethodName(route, call);
if (call.HasInput)
{
_routeInputPolicy.AlterRoute(route, call);
}
_modifications.Each(m =>
{
if (m.Filter(call))
m.Modify(route);
});
return route;
}
示例6: Build
public IRouteDefinition Build(ActionCall call)
{
var routeDefinition = call.ToRouteDefinition();
var urlAttribute = call.Method.GetAttribute<FubuDiagnosticsUrlAttribute>();
routeDefinition.Append(DiagnosticsUrls.ToRelativeUrl(urlAttribute.Url));
return routeDefinition;
}
示例7: Build
// TODO -- sucks, but need to break the IUrlPolicy signature to add diagnostics
public IRouteDefinition Build(ActionCall call)
{
var route = call.ToRouteDefinition();
// TODO -- far better diagnostics here
if (MethodToUrlBuilder.Matches(call.Method.Name))
{
MethodToUrlBuilder.Alter(route, call);
return route;
}
if (!IgnoreControllerNamespaceEntirely)
{
addNamespace(route, call);
}
if (!IgnoreControllerNamesEntirely)
{
addClassName(route, call);
}
AddMethodName(route, call);
if (call.HasInput)
{
_routeInputPolicy.AlterRoute(route, call);
}
_modifications.Where(m => m.Filter(call)).Each(m => m.Modify(route));
return route;
}
示例8: Build
public IRouteDefinition Build(ActionCall call)
{
var route = call.ToRouteDefinition();
route.Append(call.HandlerType.Name.RemoveSuffix("Controller"));
route.Append(call.Method.Name);
return route;
}
示例9: Build
public IRouteDefinition Build(ActionCall call)
{
var route = call.ToRouteDefinition();
Alter(route, call);
return route;
}
示例10: Build
public IRouteDefinition Build(ActionCall call)
{
var method = call.Method;
var definition = call.ToRouteDefinition();
definition.Append(DIAGNOSTICS_URL_ROOT + "/" + UrlFor(method));
return definition;
}
示例11: Build
public IRouteDefinition Build(ActionCall call)
{
var def = call.ToRouteDefinition();
var entityType = call.HandlerType.GetGenericArguments()[0];
def.Append(entityType.Name.ToLowerInvariant());
def.AddHttpMethodConstraint("GET");
return def;
}
示例12: Build
public IRouteDefinition Build(ActionCall call)
{
var def = call.ToRouteDefinition();
var entityType = call.HandlerType.GetGenericArguments()[0];
def.Append(entityType.Name.ToLowerInvariant());
def.Input.AddRouteInput(new RouteParameter(accessor),true);
def.AddHttpMethodConstraint("DELETE");
return def;
}
示例13: Build
public IRouteDefinition Build(ActionCall call)
{
var routeDefinition = call.ToRouteDefinition();
string strippedNamespace = "";
_markerTypes
.Each(marker =>
{
strippedNamespace = call
.HandlerType
.Namespace
.Replace(marker.Namespace + ".", string.Empty);
});
if (strippedNamespace != call.HandlerType.Namespace)
{
if (!strippedNamespace.Contains("."))
{
routeDefinition.Append(BreakUpCamelCaseWithHypen(strippedNamespace));
}
else
{
var patternParts = strippedNamespace.Split(new[] { "." }, StringSplitOptions.None);
foreach (var patternPart in patternParts)
{
routeDefinition.Append(BreakUpCamelCaseWithHypen(patternPart.Trim()));
}
}
}
var handlerName = call.HandlerType.Name;
var match = HandlerExpression.Match(handlerName);
if (match.Success && MethodToUrlBuilder.Matches(handlerName))
{
// We're forcing handlers to end with "_handler" in this case
handlerName = handlerName.Substring(0, match.Index);
var properties = call.HasInput
? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Keys
: new string[0];
MethodToUrlBuilder.Alter(routeDefinition, handlerName, properties, text => { });
if (call.HasInput)
{
routeDefinition.ApplyInputType(call.InputType());
}
}
else
{
// Otherwise we're expecting something like "GetHandler"
var httpMethod = call.HandlerType.Name.Replace(HANDLER, string.Empty);
routeDefinition.ConstrainToHttpMethods(httpMethod.ToUpper());
}
return routeDefinition;
}
示例14: Build
public IRouteDefinition Build(ActionCall call)
{
var ns = call.HandlerType.Namespace.Split('.').Last();
var route = call.ToRouteDefinition();
route.Append(ns);
route.Append(call.HandlerType.Name);
return route;
}
示例15: Build
public IRouteDefinition Build(ActionCall call)
{
var route = call.ToRouteDefinition();
var properties = (call.HasInput ? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Values : Enumerable.Empty<PropertyInfo>()).ToList();
AppendNamespace(route, call, properties, _configuration.SegmentPatterns.Where(x => x.Type == Configuration.Segment.Namespace).Select(x => x.Regex));
AppendClass(route, call, properties, _configuration.SegmentPatterns.Where(x => x.Type == Configuration.Segment.Class).Select(x => x.Regex));
AppendMethod(route, call, properties, _configuration.SegmentPatterns.Where(x => x.Type == Configuration.Segment.Method).Select(x => x.Regex));
ConstrainToHttpMethod(route, call, _configuration.HttpConstraintPatterns);
return route;
}