本文整理汇总了C#中IMethodInfo.MakeGenericMethod方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodInfo.MakeGenericMethod方法的具体用法?C# IMethodInfo.MakeGenericMethod怎么用?C# IMethodInfo.MakeGenericMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodInfo
的用法示例。
在下文中一共展示了IMethodInfo.MakeGenericMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
void Initialize(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo type, IMethodInfo method, IAttributeInfo factAttribute, object[] arguments)
{
string displayNameBase = factAttribute.GetNamedArgument<string>("DisplayName") ?? type.Name + "." + method.Name;
ITypeInfo[] resolvedTypes = null;
if (arguments != null && method.IsGenericMethodDefinition)
{
resolvedTypes = ResolveGenericTypes(method, arguments);
method = method.MakeGenericMethod(resolvedTypes);
}
Assembly = assembly;
Class = type;
Method = method;
Arguments = arguments;
DisplayName = GetDisplayNameWithArguments(displayNameBase, arguments, resolvedTypes);
SkipReason = factAttribute.GetNamedArgument<string>("Skip");
Traits = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
TestCollection = testCollection;
foreach (IAttributeInfo traitAttribute in Method.GetCustomAttributes(typeof(TraitAttribute))
.Concat(Class.GetCustomAttributes(typeof(TraitAttribute))))
{
var ctorArgs = traitAttribute.GetConstructorArguments().ToList();
Traits.Add((string)ctorArgs[0], (string)ctorArgs[1]);
}
uniqueID = new Lazy<string>(GetUniqueID, true);
}
示例2: Initialize
void Initialize(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo type, IMethodInfo method, IAttributeInfo factAttribute, object[] arguments)
{
string displayNameBase = factAttribute.GetNamedArgument<string>("DisplayName") ?? type.Name + "." + method.Name;
ITypeInfo[] resolvedTypes = null;
if (arguments != null && method.IsGenericMethodDefinition)
{
resolvedTypes = ResolveGenericTypes(method, arguments);
method = method.MakeGenericMethod(resolvedTypes);
}
Assembly = assembly;
Class = type;
Method = method;
Arguments = arguments;
DisplayName = GetDisplayNameWithArguments(displayNameBase, arguments, resolvedTypes);
SkipReason = factAttribute.GetNamedArgument<string>("Skip");
Traits = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
TestCollection = testCollection;
foreach (var traitAttribute in Method.GetCustomAttributes(typeof(ITraitAttribute))
.Concat(Class.GetCustomAttributes(typeof(ITraitAttribute))))
{
var discovererAttribute = traitAttribute.GetCustomAttributes(typeof(TraitDiscovererAttribute)).First();
var discoverer = ExtensibilityPointFactory.GetTraitDiscoverer(discovererAttribute);
if (discoverer != null)
foreach (var keyValuePair in discoverer.GetTraits(traitAttribute))
Traits.Add(keyValuePair.Key, keyValuePair.Value);
}
uniqueID = new Lazy<string>(GetUniqueID, true);
}