本文整理汇总了C#中System.Reflection.ConstructorInfo.GetGenericArguments方法的典型用法代码示例。如果您正苦于以下问题:C# ConstructorInfo.GetGenericArguments方法的具体用法?C# ConstructorInfo.GetGenericArguments怎么用?C# ConstructorInfo.GetGenericArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.ConstructorInfo
的用法示例。
在下文中一共展示了ConstructorInfo.GetGenericArguments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AreEquivalent
/// <summary>
/// Verifies that two constructors are equivalent.
/// </summary>
/// <param name="actual">The actual constructor information.</param>
/// <param name="expected">The expected constructor information.</param>
public static void AreEquivalent(ConstructorInfo actual, ConstructorInfo expected)
{
// Check member properties.
AreMembersEquivalent(actual, expected);
// Check method attributes.
Assert.That(actual.Attributes & MethodAttributes.ReservedMask, Is.EqualTo(expected.Attributes & MethodAttributes.ReservedMask));
Assert.That(actual.Attributes & MethodAttributes.SpecialName, Is.EqualTo(expected.Attributes & MethodAttributes.SpecialName));
Assert.That(actual.Attributes & MethodAttributes.VtableLayoutMask, Is.EqualTo(expected.Attributes & MethodAttributes.VtableLayoutMask));
// Check calling convention.
Assert.That(actual.CallingConvention, Is.EqualTo(expected.CallingConvention));
// Check generic parameters.
Assert.That(actual.ContainsGenericParameters, Is.EqualTo(expected.ContainsGenericParameters));
if (actual.ContainsGenericParameters)
AreTypesEquivalent(actual.GetGenericArguments(), expected.GetGenericArguments());
}
示例2: AppendConstructorInfo
static private void AppendConstructorInfo(ConstructorInfo constructor, StringBuilder sb)
{
sb.Append(".method");
foreach (var attribute in constructor.GetCustomAttributesData())
{
sb.Append(" ");
AppendCustomAttributeData(attribute, sb);
}
sb.Append(" ");
AppendMethodAttributes(sb, constructor.Attributes);
sb.Append(" ");
sb.Append("void ");
sb.Append(constructor.Name);
if (constructor.IsGenericMethod)
{
sb.Append("<");
foreach (var typeParameter in constructor.GetGenericArguments())
{
AppendType(typeParameter, sb, true);
AppendComma(sb);
}
RemoveTrailingComma(sb);
sb.Append(">");
}
sb.Append("(");
foreach (var parameter in constructor.GetParameters())
{
AppendParameterInfo(parameter, sb);
AppendComma(sb);
}
RemoveTrailingComma(sb);
sb.Append(")");
var implFlags = constructor.GetMethodImplementationFlags();
if (implFlags.HasFlag(MethodImplAttributes.IL)) sb.Append(" cil");
if (implFlags.HasFlag(MethodImplAttributes.ForwardRef)) sb.Append(" forwardref");
if (implFlags.HasFlag(MethodImplAttributes.InternalCall)) sb.Append(" internalcall");
if (implFlags.HasFlag(MethodImplAttributes.Managed)) sb.Append(" managed");
if (implFlags.HasFlag(MethodImplAttributes.Native)) sb.Append(" native");
if (implFlags.HasFlag(MethodImplAttributes.NoInlining)) sb.Append(" noinlining");
if (implFlags.HasFlag(MethodImplAttributes.NoOptimization)) sb.Append(" nooptimization");
if (implFlags.HasFlag(MethodImplAttributes.OPTIL)) sb.Append(" optil");
if (implFlags.HasFlag(MethodImplAttributes.PreserveSig)) sb.Append(" preservesig");
if (implFlags.HasFlag(MethodImplAttributes.Runtime)) sb.Append(" runtime");
if (implFlags.HasFlag(MethodImplAttributes.Synchronized)) sb.Append(" synchronized");
if (implFlags.HasFlag(MethodImplAttributes.Unmanaged)) sb.Append(" unmanaged");
}