本文整理汇总了C#中IRuntimeEnvironment.GetMemberSignaturesFromMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# IRuntimeEnvironment.GetMemberSignaturesFromMetadata方法的具体用法?C# IRuntimeEnvironment.GetMemberSignaturesFromMetadata怎么用?C# IRuntimeEnvironment.GetMemberSignaturesFromMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRuntimeEnvironment
的用法示例。
在下文中一共展示了IRuntimeEnvironment.GetMemberSignaturesFromMetadata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyMemberSignatureHelper
/// <summary>
/// Uses Reflection to verify that the specified member signature is present in emitted metadata
/// </summary>
/// <param name="appDomainHost">Unit test AppDomain host</param>
/// <param name="fullyQualifiedTypeName">
/// Fully qualified type name for member
/// Names must be in format recognized by reflection
/// e.g. MyType<T>.MyNestedType<T, U> => MyType`1+MyNestedType`2
/// </param>
/// <param name="memberName">
/// Name of member on specified type whose signature needs to be verified
/// Names must be in format recognized by reflection
/// e.g. For explicitly implemented member - I1<string>.Method => I1<System.String>.Method
/// </param>
/// <param name="expectedSignature">
/// Baseline string for signature of specified member
/// Skip this argument to get an error message that shows all available signatures for specified member
/// This argument is passed by reference and it will be updated with a formatted form of the baseline signature for error reporting purposes
/// </param>
/// <param name="actualSignatures">List of found signatures matching member name</param>
/// <returns>True if a matching member signature was found, false otherwise</returns>
private static bool VerifyMemberSignatureHelper(
IRuntimeEnvironment appDomainHost, string fullyQualifiedTypeName, string memberName,
ref string expectedSignature, out List<string> actualSignatures)
{
Assert.False(string.IsNullOrWhiteSpace(fullyQualifiedTypeName), "'fullyQualifiedTypeName' can't be null or empty");
Assert.False(string.IsNullOrWhiteSpace(memberName), "'memberName' can't be null or empty");
var retVal = true; actualSignatures = new List<string>();
var signatures = appDomainHost.GetMemberSignaturesFromMetadata(fullyQualifiedTypeName, memberName);
var signatureAssertText = "Signature(\"" + fullyQualifiedTypeName + "\", \"" + memberName + "\", \"{0}\"),";
if (!string.IsNullOrWhiteSpace(expectedSignature))
{
expectedSignature = expectedSignature.Replace("\"", "\\\"");
}
expectedSignature = string.Format(signatureAssertText, expectedSignature);
if (signatures.Count > 1)
{
var found = false;
foreach (var signature in signatures)
{
var actualSignature = signature.Replace("\"", "\\\"");
actualSignature = string.Format(signatureAssertText, actualSignature);
if (actualSignature == expectedSignature)
{
actualSignatures.Clear();
actualSignatures.Add(actualSignature);
found = true; break;
}
else
{
actualSignatures.Add(actualSignature);
}
}
if (!found)
{
retVal = false;
}
}
else if (signatures.Count == 1)
{
var actualSignature = signatures.First().Replace("\"", "\\\"");
actualSignature = string.Format(signatureAssertText, actualSignature);
actualSignatures.Add(actualSignature);
if (expectedSignature != actualSignature)
{
retVal = false;
}
}
else
{
retVal = false;
}
return retVal;
}