本文整理汇总了C#中HttpParameterDescriptor类的典型用法代码示例。如果您正苦于以下问题:C# HttpParameterDescriptor类的具体用法?C# HttpParameterDescriptor怎么用?C# HttpParameterDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpParameterDescriptor类属于命名空间,在下文中一共展示了HttpParameterDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ODataFormatterParameterBinding
public ODataFormatterParameterBinding(HttpParameterDescriptor descriptor, MediaTypeFormatter formatter)
: base(descriptor)
{
if (formatter == null)
{
throw Error.ArgumentNull("formatter");
}
_formatter = formatter;
}
示例2: GetDocumentation
public string GetDocumentation(HttpParameterDescriptor parameterDescriptor)
{
var reflectedParameterDescriptor = parameterDescriptor as ReflectedHttpParameterDescriptor;
if (reflectedParameterDescriptor != null)
{
XPathNavigator memberNode = GetMemberNode(reflectedParameterDescriptor.ActionDescriptor);
if (memberNode != null)
{
string parameterName = reflectedParameterDescriptor.ParameterInfo.Name;
XPathNavigator parameterNode =
memberNode.SelectSingleNode(string.Format("param[@name='{0}']", parameterName));
if (parameterNode != null)
{
return parameterNode.Value.Trim();
}
}
}
return string.Empty;
}
示例3: BodyAndUriParameterBinding
public BodyAndUriParameterBinding(HttpParameterDescriptor descriptor)
: base(descriptor)
{
var httpConfiguration = descriptor.Configuration;
Formatters = httpConfiguration.Formatters;
BodyModelValidator = httpConfiguration.Services.GetBodyModelValidator();
}
示例4: ResourceParameterBinding
public ResourceParameterBinding(
ScimServerConfiguration serverConfiguration,
HttpParameterDescriptor parameter)
: base(parameter)
{
_ServerConfiguration = serverConfiguration;
}
示例5: ODataParameterDescriptor
public ODataParameterDescriptor(string parameterName, Type parameterType, bool isOptional, HttpParameterDescriptor reflectedHttpParameterDescriptor)
{
ParameterName = parameterName;
ParameterType = parameterType;
IsOptional = isOptional;
ReflectedHttpParameterDescriptor = reflectedHttpParameterDescriptor;
}
示例6: GetBinding
public override HttpParameterBinding GetBinding(HttpParameterDescriptor parameter)
{
if (parameter == null)
throw new ArgumentException("Invalid parameter");
return new TransferujPlResponseModelBinder(parameter);
}
示例7: HookupParameterBinding
/// <summary>
/// Method that implements parameter binding hookup to the global configuration object's
/// ParameterBindingRules collection delegate.
///
/// This routine filters based on POST/PUT method status and simple parameter
/// types.
/// </summary>
/// <example>
/// GlobalConfiguration.Configuration.
/// .ParameterBindingRules
/// .Insert(0,SimplePostVariableParameterBinding.HookupParameterBinding);
/// </example>
/// <param name="descriptor"></param>
/// <returns></returns>
public static HttpParameterBinding HookupParameterBinding(HttpParameterDescriptor descriptor)
{
//To see is it mark the flag
if (descriptor.ActionDescriptor.GetCustomAttributes<System.Web.Http.MultiParameterSupportAttribute>().Count <= 0)
return null;
var supportedMethods = descriptor.ActionDescriptor.SupportedHttpMethods;
// Only apply this binder on POST and PUT operations
if (supportedMethods.Contains(HttpMethod.Post) ||
supportedMethods.Contains(HttpMethod.Put))
{
var supportedTypes = new Type[] { typeof(string),
typeof(int),
typeof(int?),
typeof(decimal),
typeof(decimal?),
typeof(double),
typeof(double?),
typeof(long),
typeof(long?),
typeof(bool),
typeof(bool?),
typeof(DateTime),
typeof(DateTime?),
typeof(byte[])
};
if (supportedTypes.Count(typ => typ == descriptor.ParameterType) > 0)
return new SimplePostVariableParameterBinding(descriptor);
}
return null;
}
开发者ID:DoraemonYu,项目名称:SimplePostVariableParameterBindingExtended,代码行数:48,代码来源:SimplePostModelBinding.cs
示例8: GetBinding
/// <summary>
/// Gets the parameter binding.
/// </summary>
/// <returns>The parameter binding.</returns>
/// <param name="parameter">The parameter description.</param>
public override HttpParameterBinding GetBinding(HttpParameterDescriptor parameter)
{
// Preconditions
Raise.ArgumentNullException.IfIsNull(parameter, nameof(parameter));
return new NakedBodyParameterBinding(parameter);
}
示例9: CatchAllRouteParameterBinding
public CatchAllRouteParameterBinding(
HttpParameterDescriptor descriptor, char delimiter)
: base(descriptor)
{
_parameterName = descriptor.ParameterName;
_delimiter = delimiter;
}
示例10: GetParameterBinding
// Determine how a single parameter will get bound.
// This is all sync. We don't need to actually read the body just to determine that we'll bind to the body.
protected virtual HttpParameterBinding GetParameterBinding(HttpParameterDescriptor parameter)
{
// Attribute has the highest precedence
// Presence of a model binder attribute overrides.
ParameterBindingAttribute attr = parameter.ParameterBinderAttribute;
if (attr != null)
{
return attr.GetBinding(parameter);
}
// No attribute, so lookup in global map.
ParameterBindingRulesCollection pb = parameter.Configuration.ParameterBindingRules;
if (pb != null)
{
HttpParameterBinding binding = pb.LookupBinding(parameter);
if (binding != null)
{
return binding;
}
}
// Not explicitly specified in global map or attribute.
// Use a default policy to determine it. These are catch-all policies.
Type type = parameter.ParameterType;
if (TypeHelper.IsSimpleUnderlyingType(type) || TypeHelper.HasStringConverter(type))
{
// For simple types, the default is to look in URI. Exactly as if the parameter had a [FromUri] attribute.
return parameter.BindWithAttribute(new FromUriAttribute());
}
// Fallback. Must be a complex type. Default is to look in body. Exactly as if this type had a [FromBody] attribute.
attr = new FromBodyAttribute();
return attr.GetBinding(parameter);
}
示例11: GetDocumentation
/// <summary>
/// Gets the documentation based on <see cref="System.Web.Http.Controllers.HttpParameterDescriptor" />.
/// </summary>
/// <param name="parameterDescriptor">The parameter descriptor.</param>
/// <returns>The documentation for the controller.</returns>
public string GetDocumentation(HttpParameterDescriptor parameterDescriptor)
{
return this.sources
.Select(source => source.GetDocumentation(parameterDescriptor))
.Where(documentation => !string.IsNullOrEmpty(documentation))
.FirstOrDefault();
}
示例12: SimpleApiParameterDescriptor
public SimpleApiParameterDescriptor(HttpParameterDescriptor arg, string routePath)
{
this.Name = arg.ParameterName;
this.IsOptional = arg.IsOptional;
if (this.IsOptional)
{
this.DefaultValue = arg.DefaultValue;
}
var indexOfQueryString = routePath.IndexOf('?');
if (arg.ParameterBinderAttribute is FromBodyAttribute)
{
this.CallingConvention = "body";
}
else
{
var indexOfParameter = routePath.IndexOf("{" + arg.ParameterName + "}", StringComparison.InvariantCultureIgnoreCase);
if (indexOfQueryString > 0 && indexOfParameter > indexOfQueryString)
{
this.CallingConvention = "query-string";
}
else if (indexOfParameter > 0)
{
this.CallingConvention = "uri";
}
else
{
this.CallingConvention = "unknown";
}
}
}
示例13: ScimQueryOptionsParameterBinding
public ScimQueryOptionsParameterBinding(
HttpParameterDescriptor descriptor,
ScimServerConfiguration serverConfiguration)
: base(descriptor)
{
_ServerConfiguration = serverConfiguration;
}
示例14: GetBinding
public override HttpParameterBinding GetBinding(HttpParameterDescriptor parameter)
{
if (parameter == null)
throw new ArgumentException("Invalid parameter");
return new NakedBodyParameterBinding(parameter);
}
示例15: GetDocumentation
public string GetDocumentation(HttpParameterDescriptor parameterDescriptor)
{
var attr = parameterDescriptor.ActionDescriptor
.GetCustomAttributes<ApiParameterDocAttribute>()
.FirstOrDefault(p => p.Parameter == parameterDescriptor.ParameterName);
return attr != null ? attr.Documentation : "";
}