本文整理汇总了C#中ActionCall.InputType方法的典型用法代码示例。如果您正苦于以下问题:C# ActionCall.InputType方法的具体用法?C# ActionCall.InputType怎么用?C# ActionCall.InputType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionCall
的用法示例。
在下文中一共展示了ActionCall.InputType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: AddBasicRouteInputs
public static void AddBasicRouteInputs(ActionCall call, RouteDefinition route)
{
call.InputType()
.GetProperties()
.Where(x => x.HasAttribute<RouteInputAttribute>())
.Each(prop => route.Append("{" + prop.Name + "}"));
route.ApplyInputType(call.InputType());
}
示例3: 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;
}
示例4: ActionIsIncluded
public static bool ActionIsIncluded(ActionCall call)
{
if (call.HasAttribute<JsonBindingAttribute>()) return true;
if (call.InputType() != null && call.InputType().HasAttribute<JsonBindingAttribute>())
{
return true;
}
return false;
}
示例5: 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);
}
示例6: IsPassThrough
public static bool IsPassThrough(ActionCall call)
{
if (call.HasAttribute<PassThroughAuthenticationAttribute>()) return true;
if (call.InputType() != null && call.InputType().HasAttribute<PassThroughAuthenticationAttribute>())
{
return true;
}
return false;
}
示例7: ActionIsExempted
public static bool ActionIsExempted(ActionCall call)
{
if (call.HasAttribute<NotAuthenticatedAttribute>()) return true;
if (call.InputType() != null && call.InputType().HasAttribute<NotAuthenticatedAttribute>())
{
return true;
}
return false;
}
示例8: Alter
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());
}
}
示例9: Alter
public static void Alter(IRouteDefinition route, ActionCall call)
{
var properties = call.HasInput
? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Keys
: new string[0];
Alter(route, call.Method.Name, properties, text => call.Trace(text));
if (call.HasInput)
{
route.ApplyInputType(call.InputType());
}
}
示例10: Matches
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;
}
示例11: GetSwaggerOperations
public IEnumerable<Operation> GetSwaggerOperations(ActionCall call)
{
var parameters = createParameters(call);
var outputType = call.OutputType();
var route = call.ParentChain().Route;
var verbs = getRouteVerbs(route);
return verbs.Select(verb =>
{
var summary = call.InputType().GetAttribute<DescriptionAttribute>(d => d.Description);
return new Operation
{
parameters = parameters.ToArray(),
httpMethod = verb,
responseTypeInternal = outputType.FullName,
responseClass = outputType.Name,
nickname = call.InputType().Name,
summary = summary,
//TODO not sure how we'd support error responses
errorResponses = new ErrorResponses[0],
//TODO get notes, nickname, summary from metadata?
};
});
}
示例12: Build
public IRouteDefinition Build(ActionCall call)
{
var pattern = call.Method.GetAttribute<UrlPatternAttribute>().Pattern;
return call.HasInput
? RouteBuilder.Build(call.InputType(), pattern)
: new RouteDefinition(pattern);
}
示例13: Alter
public override void Alter(ActionCall call)
{
var inputType = call.InputType();
Types.Each(attType =>
{
var ruleType = RuleTypeFor(inputType, attType);
call.ParentChain().Authorization.AddPolicy(ruleType);
});
}
示例14: Alter
public static void Alter(IRouteDefinition route, ActionCall call)
{
var properties = call.HasInput
? new TypeDescriptorCache().GetPropertiesFor(call.InputType()).Keys
: new string[0];
Alter(route, call.Method.Name, properties);
if (call.HasInput)
{
route.ApplyInputType(call.InputType());
if (call.InputType().CanBeCastTo<ResourcePath>())
{
ResourcePath.AddResourcePathInputs(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;
}