本文整理汇总了C#中System.Reflection.ParameterInfo.GetXmlDocumentation方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterInfo.GetXmlDocumentation方法的具体用法?C# ParameterInfo.GetXmlDocumentation怎么用?C# ParameterInfo.GetXmlDocumentation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.ParameterInfo
的用法示例。
在下文中一共展示了ParameterInfo.GetXmlDocumentation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePrimitiveParameter
/// <summary>Creates a primitive parameter for the given parameter information reflection object.</summary>
/// <param name="name">The name.</param>
/// <param name="parameter">The parameter information.</param>
/// <returns>The created parameter.</returns>
public SwaggerParameter CreatePrimitiveParameter(string name, ParameterInfo parameter)
{
return CreatePrimitiveParameter(name, parameter.GetXmlDocumentation(), parameter.ParameterType, parameter.GetCustomAttributes().ToList());
}
示例2: AddPrimitiveParametersFromUri
private void AddPrimitiveParametersFromUri(string name, SwaggerOperation operation, ParameterInfo parameter, JsonObjectTypeDescription typeDescription, SwaggerGenerator swaggerGenerator)
{
if (typeDescription.Type.HasFlag(JsonObjectType.Array))
{
var operationParameter = swaggerGenerator.CreatePrimitiveParameter(name,
parameter.GetXmlDocumentation(), parameter.ParameterType.GetEnumerableItemType(), parameter.GetCustomAttributes().ToList());
operationParameter.Kind = SwaggerParameterKind.Query;
operationParameter.CollectionFormat = SwaggerParameterCollectionFormat.Multi;
operation.Parameters.Add(operationParameter);
}
else
{
foreach (var property in parameter.ParameterType.GetRuntimeProperties())
{
var attributes = property.GetCustomAttributes().ToList();
var fromQueryAttribute = attributes.SingleOrDefault(a => a.GetType().Name == "FromQueryAttribute");
var propertyName = TryGetStringPropertyValue(fromQueryAttribute, "Name") ?? JsonPathUtilities.GetPropertyName(property, _settings.DefaultPropertyNameHandling);
var operationParameter = swaggerGenerator.CreatePrimitiveParameter(propertyName, property.GetXmlSummary(), property.PropertyType, attributes);
// TODO: Check if required can be controlled with mechanisms other than RequiredAttribute
var parameterInfo = JsonObjectTypeDescription.FromType(property.PropertyType, attributes, _settings.DefaultEnumHandling);
var isFileArray = IsFileArray(property.PropertyType, parameterInfo);
if (parameterInfo.Type == JsonObjectType.File || isFileArray)
InitializeFileParameter(operationParameter, isFileArray);
else
operationParameter.Kind = SwaggerParameterKind.Query;
operation.Parameters.Add(operationParameter);
}
}
}
示例3: CreateBodyParameter
/// <summary>Creates a primitive parameter for the given parameter information reflection object.</summary>
/// <param name="name">The name.</param>
/// <param name="parameter">The parameter.</param>
/// <returns></returns>
public SwaggerParameter CreateBodyParameter(string name, ParameterInfo parameter)
{
var isRequired = IsParameterRequired(parameter);
var typeDescription = JsonObjectTypeDescription.FromType(parameter.ParameterType, parameter.GetCustomAttributes(), _settings.DefaultEnumHandling);
var operationParameter = new SwaggerParameter
{
Name = name,
Kind = SwaggerParameterKind.Body,
IsRequired = isRequired,
IsNullableRaw = typeDescription.IsNullable,
Schema = GenerateAndAppendSchemaFromType(parameter.ParameterType, !isRequired, parameter.GetCustomAttributes()),
};
var description = parameter.GetXmlDocumentation();
if (description != string.Empty)
operationParameter.Description = description;
return operationParameter;
}
示例4: AddFileParameter
private void AddFileParameter(ParameterInfo parameter, bool isFileArray, SwaggerOperation operation, SwaggerGenerator swaggerGenerator)
{
var attributes = parameter.GetCustomAttributes().ToList();
// TODO: Check if there is a way to control the property name
var operationParameter = swaggerGenerator.CreatePrimitiveParameter(parameter.Name, parameter.GetXmlDocumentation(), parameter.ParameterType, attributes);
InitializeFileParameter(operationParameter, isFileArray);
operation.Parameters.Add(operationParameter);
}