本文整理汇总了C#中HttpParameterDescriptor.GetCustomAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# HttpParameterDescriptor.GetCustomAttributes方法的具体用法?C# HttpParameterDescriptor.GetCustomAttributes怎么用?C# HttpParameterDescriptor.GetCustomAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpParameterDescriptor
的用法示例。
在下文中一共展示了HttpParameterDescriptor.GetCustomAttributes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1:
string IDocumentationProvider.GetDocumentation(HttpParameterDescriptor parameterDescriptor)
{
var actionDoc = parameterDescriptor.GetCustomAttributes<ParameterDocAttribute>().FirstOrDefault();
if (actionDoc != null)
{
return actionDoc.Documentation;
}
return string.Format("Documentation for '{0}'.", parameterDescriptor.ParameterName);
}
示例2: PrepareByOptionAttribute
public static void PrepareByOptionAttribute(ResourceApiOperationParameter parameter, HttpParameterDescriptor parameterDescriptor)
{
var attributes = parameterDescriptor.GetCustomAttributes<SwaggerOptionsAttribute>();
if (attributes.Count > 0)
{
var att = attributes[0] as SwaggerOptionsAttribute;
if (!String.IsNullOrWhiteSpace(att.Name))
{
parameter.name = att.Name;
}
}
}
示例3: DetermineBinding
// 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.
private HttpParameterBinding DetermineBinding(HttpParameterDescriptor parameter)
{
// Look at Parameter attributes?
// [FromBody] - we use Formatter.
bool hasFromBody = parameter.GetCustomAttributes<FromBodyAttribute>().Any();
ModelBinderAttribute attr = parameter.ModelBinderAttribute;
if (hasFromBody)
{
if (attr != null)
{
string message = Error.Format(SRResources.ParameterBindingConflictingAttributes, parameter.ParameterName);
return new ErrorParameterBinding(parameter, message);
}
return MakeBodyBinding(parameter); // It's from the body. Uses a formatter.
}
// Presence of a model binder attribute overrides.
if (attr != null)
{
return GetBinding(parameter, attr);
}
// No attribute, key off type
Type type = parameter.ParameterType;
if (TypeHelper.IsSimpleUnderlyingType(type) || TypeHelper.HasStringConverter(type))
{
attr = new ModelBinderAttribute(); // use default settings
return GetBinding(parameter, attr);
}
// Handle special types
if (type == typeof(CancellationToken))
{
return new CancellationTokenParameterBinding(parameter);
}
if (type == typeof(HttpRequestMessage))
{
return new HttpRequestParameterBinding(parameter);
}
if (typeof(HttpContent).IsAssignableFrom(type))
{
string message = Error.Format(SRResources.ParameterBindingIllegalType, type.Name, parameter.ParameterName);
return new ErrorParameterBinding(parameter, message);
}
// Fallback. Must be a complex type. Default is to look in body.
return MakeBodyBinding(parameter);
}
示例4: GetDocumentation
public string GetDocumentation(HttpParameterDescriptor parameterDescriptor)
{
var parameterDescriptionAttributes = parameterDescriptor.GetCustomAttributes<ParameterDescriptionAttribute>();
return parameterDescriptionAttributes.Any() ? parameterDescriptionAttributes.First().Description : string.Empty;
}