本文整理汇总了C#中HttpActionDescriptor.GetParameters方法的典型用法代码示例。如果您正苦于以下问题:C# HttpActionDescriptor.GetParameters方法的具体用法?C# HttpActionDescriptor.GetParameters怎么用?C# HttpActionDescriptor.GetParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpActionDescriptor
的用法示例。
在下文中一共展示了HttpActionDescriptor.GetParameters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Map
public HttpParameterDescriptor Map(Parameter swaggerParameter, int parameterIndex, HttpActionDescriptor actionDescriptor)
{
// Maybe the parameter is a key parameter, e.g., where Id in the URI path maps to a parameter named 'key'
if (swaggerParameter.description != null && swaggerParameter.description.StartsWith("key:"))
{
// Find either a single 'key' in the route or composite keys
// which take the form of key<parameter name>
var keyParameterName = swaggerParameter
.description
.Replace(FindKeyReplacementSubStr,
String.Empty)
.ToLower();
var parameterDescriptor =
actionDescriptor
.GetParameters()?
.SingleOrDefault(descriptor =>
descriptor.ParameterName.ToLower() == KeyName
|| descriptor.ParameterName.ToLower().Equals(keyParameterName)
);
if (parameterDescriptor != null && !parameterDescriptor.IsODataLibraryType())
{
var httpControllerDescriptor = actionDescriptor.ControllerDescriptor;
Contract.Assume(httpControllerDescriptor != null);
return new ODataParameterDescriptor(swaggerParameter.name, parameterDescriptor.ParameterType, parameterDescriptor.IsOptional, parameterDescriptor)
{
Configuration = httpControllerDescriptor.Configuration,
ActionDescriptor = actionDescriptor,
ParameterBinderAttribute = parameterDescriptor.ParameterBinderAttribute
};
}
}
return null;
}
示例2: CreateParameterDescription
private IList<ApiParameterDescription> CreateParameterDescription(HttpActionBinding actionBinding,HttpActionDescriptor actionDescriptor)
{
IList<ApiParameterDescription> parameterDescriptions = new List<ApiParameterDescription>();
// try get parameter binding information if available
if (actionBinding != null)
{
HttpParameterBinding[] parameterBindings = actionBinding.ParameterBindings;
if (parameterBindings != null)
{
foreach (HttpParameterBinding parameter in parameterBindings)
{
parameterDescriptions.Add(CreateParameterDescriptionFromBinding(parameter));
}
}
}
else
{
Collection<HttpParameterDescriptor> parameters = actionDescriptor.GetParameters();
if (parameters != null)
{
foreach (HttpParameterDescriptor parameter in parameters)
{
parameterDescriptions.Add(CreateParameterDescriptionFromDescriptor(parameter));
}
}
}
return parameterDescriptions;
}
示例3: ActionHasChangeSetEntityParameter
internal static bool ActionHasChangeSetEntityParameter(HttpActionDescriptor actionDescriptor)
{
Contract.Assert(actionDescriptor != null);
var parameters = actionDescriptor.GetParameters();
return (parameters.Count > 0) && IsChangeSetEntityParameter(parameters[0]);
}
示例4: GetParameterValuePairs
private IDictionary<string, object> GetParameterValuePairs(HttpActionDescriptor actionDescriptor)
{
IDictionary<string, object> parameterValuePairs = new Dictionary<string, object>();
foreach (SwaggerDefaultValue defaultValue in actionDescriptor.GetCustomAttributes<SwaggerDefaultValue>())
{
parameterValuePairs.Add(defaultValue.Name, defaultValue.Value);
}
foreach (var parameter in actionDescriptor.GetParameters())
{
if (!parameter.ParameterType.IsPrimitive)
{
foreach (PropertyInfo property in parameter.ParameterType.GetProperties())
{
var defaultValue = GetDefaultValue(property);
if (defaultValue != null)
{
parameterValuePairs.Add(property.Name, defaultValue);
}
}
}
}
return parameterValuePairs;
}
示例5: Map
public HttpParameterDescriptor Map(Parameter swaggerParameter, int parameterIndex, HttpActionDescriptor actionDescriptor)
{
var httpParameterDescriptors = actionDescriptor.GetParameters();
Contract.Assume(httpParameterDescriptors != null);
return httpParameterDescriptors
.SingleOrDefault(descriptor => string.Equals(descriptor.ParameterName, swaggerParameter.name, StringComparison.CurrentCultureIgnoreCase));
}
示例6: GetFilters
/// <summary>
/// Returns an enumeration of filters.
/// </summary>
/// <param name="configuration">The HTTP configuration.</param>
/// <param name="actionDescriptor">The action descriptor.</param>
/// <returns>
/// An enumeration of filters.
/// </returns>
public IEnumerable<FilterInfo> GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor) {
if (actionDescriptor == null ||
(!IsIQueryable(actionDescriptor.ReturnType)) ||
actionDescriptor.GetCustomAttributes<QueryableAttribute>().Any() ||
actionDescriptor.GetParameters().Any(parameter => typeof (ODataQueryOptions).IsAssignableFrom(parameter.ParameterType)))
return Enumerable.Empty<FilterInfo>();
return new[] {new FilterInfo(_filter, FilterScope.Global)};
}
示例7: ParameterDescriptions
private static string ParameterDescriptions(HttpActionDescriptor actionDescripton)
{
var description = new StringBuilder();
foreach (var parameter in actionDescripton.GetParameters())
{
description.AppendFormat("{0}:{1}/", parameter.ParameterType, parameter.ParameterName);
}
return description.ToString();
}
示例8: GetNodeFor
private XPathNavigator GetNodeFor(HttpActionDescriptor actionDescriptor)
{
var controllerName = actionDescriptor.ControllerDescriptor.ControllerType.FullName;
var actionName = actionDescriptor.ActionName;
var parameters = String.Join(",", actionDescriptor.GetParameters()
.Select(paramDesc => TypeNameFor(paramDesc.ParameterType)));
var xpath = String.Format(MethodExpression, controllerName, actionName, parameters);
return _navigator.SelectSingleNode(xpath);
}
示例9: Map
public HttpParameterDescriptor Map(Parameter swaggerParameter, int parameterIndex, HttpActionDescriptor actionDescriptor)
{
Contract.Requires(swaggerParameter != null);
Contract.Requires(parameterIndex >= 0);
Contract.Requires(actionDescriptor != null);
Contract.Requires(actionDescriptor.GetParameters() != null);
//Contract.Ensures(Contract.Result<HttpParameterDescriptor>() == null || Contract.Result<HttpParameterDescriptor>().Configuration != null);
throw new NotImplementedException();
}
示例10: Map
public HttpParameterDescriptor Map(Parameter swaggerParameter, int parameterIndex, HttpActionDescriptor actionDescriptor)
{
if ([email protected] != "query" && parameterIndex < actionDescriptor.GetParameters().Count)
{
var parameterDescriptor = actionDescriptor.GetParameters()[parameterIndex];
if (parameterDescriptor != null && !parameterDescriptor.IsODataLibraryType())
{
var httpControllerDescriptor = actionDescriptor.ControllerDescriptor;
Contract.Assume(httpControllerDescriptor != null);
return new ODataParameterDescriptor(swaggerParameter.name, parameterDescriptor.ParameterType, parameterDescriptor.IsOptional, parameterDescriptor)
{
Configuration = httpControllerDescriptor.Configuration,
ActionDescriptor = actionDescriptor,
ParameterBinderAttribute = parameterDescriptor.ParameterBinderAttribute
};
}
}
return null;
}
示例11: ActionDescriptorToString
public static string ActionDescriptorToString(HttpActionDescriptor actionDescriptor)
{
Contract.Assert(actionDescriptor != null);
string parameterList = String.Join(", ",
actionDescriptor.GetParameters().Select<HttpParameterDescriptor, string>(
(p) => p.ParameterType.Name + " " + p.ParameterName));
return actionDescriptor.ActionName + "(" + parameterList + ")";
}
示例12: GetBinding
public override HttpActionBinding GetBinding(HttpActionDescriptor actionDescriptor)
{
var actionBinding = new MvcActionBinding();
HttpParameterDescriptor[] parameters = actionDescriptor.GetParameters().ToArray();
HttpParameterBinding[] binders = Array.ConvertAll(parameters, DetermineBinding);
actionBinding.ParameterBindings = binders;
return actionBinding;
}
示例13: GetFilters
public IEnumerable<FilterInfo> GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor)
{
if (actionDescriptor == null ||
actionDescriptor.GetCustomAttributes<QueryableAttribute>().Any() || // if method already has a QueryableAttribute (or subclass) then skip it.
actionDescriptor.GetParameters().Any(parameter => typeof(ODataQueryOptions).IsAssignableFrom(parameter.ParameterType))
)
{
return Enumerable.Empty<FilterInfo>();
}
return new[] { new FilterInfo(_filter, FilterScope.Global) };
}
示例14: GetFilters
/// <summary>
/// Provides filters to apply to the specified action.
/// </summary>
/// <param name="configuration">The server configuration.</param>
/// <param name="actionDescriptor">The action descriptor for the action to provide filters for.</param>
/// <returns>
/// The filters to apply to the specified action.
/// </returns>
public IEnumerable<FilterInfo> GetFilters(HttpConfiguration configuration, HttpActionDescriptor actionDescriptor)
{
// Actions with a bound parameter of type ODataQueryOptions do not support the query filter
// The assumption is that the action will handle the querying within the action implementation
if (actionDescriptor != null && IsIQueryable(actionDescriptor.ReturnType) &&
!actionDescriptor.GetParameters().Any(parameter => typeof(ODataQueryOptions).IsAssignableFrom(parameter.ParameterType)))
{
return new FilterInfo[] { new FilterInfo(QueryFilter, FilterScope.Global) };
}
return Enumerable.Empty<FilterInfo>();
}
示例15: GetXPathFor
private static string GetXPathFor(HttpActionDescriptor actionDescriptor)
{
var controllerName = actionDescriptor.ControllerDescriptor.ControllerType.FullName;
var actionName = actionDescriptor.ActionName;
var paramTypeNames = actionDescriptor.GetParameters()
.Select(paramDesc => TypeNameFor(paramDesc.ParameterType))
.ToArray();
var parameters = (paramTypeNames.Any())
? String.Format("({0})", String.Join(",", paramTypeNames))
: String.Empty;
return String.Format(MethodExpression, controllerName, actionName, parameters);
}