本文整理汇总了C#中System.Reflection.ParameterInfo.GetRequiredCustomModifiers方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterInfo.GetRequiredCustomModifiers方法的具体用法?C# ParameterInfo.GetRequiredCustomModifiers怎么用?C# ParameterInfo.GetRequiredCustomModifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.ParameterInfo
的用法示例。
在下文中一共展示了ParameterInfo.GetRequiredCustomModifiers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetSignature
private void SetSignature(Type returnType, ParameterInfo returnParameter, Type[] parameters,
ParameterInfo[] baseMethodParameters)
{
builder.SetSignature(
returnType,
#if SILVERLIGHT
null,
null,
#else
returnParameter.GetRequiredCustomModifiers(),
returnParameter.GetOptionalCustomModifiers(),
#endif
parameters,
#if SILVERLIGHT
null,
null
#else
baseMethodParameters.Select(x => x.GetRequiredCustomModifiers()).ToArray(),
baseMethodParameters.Select(x => x.GetOptionalCustomModifiers()).ToArray()
#endif
);
}
示例2: AppendParameterInfo
static private void AppendParameterInfo(ParameterInfo parameter, StringBuilder sb)
{
foreach (var attribute in parameter.GetCustomAttributesData())
{
// these are pseudo-custom attributes that are added by Reflection but don't appear in metadata as custom attributes:
if (attribute.AttributeType != typeof(OptionalAttribute) &&
attribute.AttributeType != typeof(InAttribute) &&
attribute.AttributeType != typeof(OutAttribute) &&
attribute.AttributeType != typeof(MarshalAsAttribute))
{
AppendCustomAttributeData(attribute, sb);
sb.Append(" ");
}
}
foreach (var modreq in parameter.GetRequiredCustomModifiers())
{
sb.Append("modreq(");
AppendType(modreq, sb);
sb.Append(") ");
}
foreach (var modopt in parameter.GetOptionalCustomModifiers())
{
sb.Append("modopt(");
AppendType(modopt, sb);
sb.Append(") ");
}
int length = sb.Length;
AppendParameterAttributes(sb, parameter.Attributes, all: false);
if (sb.Length > length)
{
sb.Append(" ");
}
AppendType(parameter.ParameterType, sb);
if (!string.IsNullOrWhiteSpace(parameter.Name)) // If this is not the 'return' parameter
{
sb.Append(" ");
sb.Append(parameter.Name);
var defaultValue = parameter.RawDefaultValue;
if (defaultValue != DBNull.Value)
{
AppendValue(defaultValue, sb);
}
}
}
示例3: ParameterTypeMatches
private static bool ParameterTypeMatches(Type type, ParameterInfo param)
{
if (!type.IsEquivalentTo(param.ParameterType))
{
return false;
}
// TODO (tomat): how expensive is GetOptional/GetRequiredCustomModifiers?
ModifiedType modified = type as ModifiedType;
return IsEquivalentTo(modified != null ? modified.OptionalModifiers : null, param.GetOptionalCustomModifiers())
&& IsEquivalentTo(modified != null ? modified.RequiredModifiers : null, param.GetRequiredCustomModifiers());
}
示例4: AreParametersEquivalent
/// <summary>
/// Verifies that two parameters are equivalent.
/// </summary>
/// <param name="actual">The actual parameter information.</param>
/// <param name="expected">The expected parameter information.</param>
private static void AreParametersEquivalent(ParameterInfo actual, ParameterInfo expected)
{
// Check parameter properties.
Assert.That(actual.Name, Is.EqualTo(expected.Name));
Assert.That(actual.IsIn, Is.EqualTo(expected.IsIn));
Assert.That(actual.IsLcid, Is.EqualTo(expected.IsLcid));
Assert.That(actual.IsOptional, Is.EqualTo(expected.IsOptional));
Assert.That(actual.IsOut, Is.EqualTo(expected.IsOut));
Assert.That(actual.IsRetval, Is.EqualTo(expected.IsRetval));
Assert.That(actual.Position, Is.EqualTo(expected.Position));
// Check parameter attributes.
Assert.That(actual.Attributes, Is.EqualTo(expected.Attributes));
// Check parameter type.
AreTypesEquivalent(actual.ParameterType, expected.ParameterType);
// Check default value.
Assert.That(actual.DefaultValue, Is.EqualTo(expected.DefaultValue));
Assert.That(actual.RawDefaultValue, Is.EqualTo(expected.RawDefaultValue));
// Check custom modifiers.
Assert.That(actual.GetOptionalCustomModifiers(), Is.EqualTo(expected.GetOptionalCustomModifiers()));
Assert.That(actual.GetRequiredCustomModifiers(), Is.EqualTo(expected.GetRequiredCustomModifiers()));
}
示例5: SetSignature
private void SetSignature(Type returnType, ParameterInfo returnParameter, Type[] parameters,
ParameterInfo[] baseMethodParameters)
{
builder.SetSignature(
returnType,
#if FEATURE_EMIT_CUSTOMMODIFIERS
returnParameter.GetRequiredCustomModifiers(),
returnParameter.GetOptionalCustomModifiers(),
#else
null,
null,
#endif
parameters,
#if FEATURE_EMIT_CUSTOMMODIFIERS
baseMethodParameters.Select(x => x.GetRequiredCustomModifiers()).ToArray(),
baseMethodParameters.Select(x => x.GetOptionalCustomModifiers()).ToArray()
#else
null,
null
#endif
);
}