本文整理汇总了C#中Function.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Function.GetProperty方法的具体用法?C# Function.GetProperty怎么用?C# Function.GetProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Function
的用法示例。
在下文中一共展示了Function.GetProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConsumeExpectedException
private bool ConsumeExpectedException(Function function, System.Exception pEx)
{
if (function.HasCustomAttribute("NUnit.Framework.ExpectedExceptionAttribute"))
{
System.Attribute pAttributeExpectedException = function.GetAttribute("NUnit.Framework.ExpectedExceptionAttribute");
if (pAttributeExpectedException != null)
{
System.Type pExpectedExceptionType = GetExpectedExceptionType(function, pAttributeExpectedException);
if (pExpectedExceptionType != null)
{
string pExpectedExceptionName = (System.String)function.GetProperty(pExpectedExceptionType, "FullName");
string pExpectedMessage = (System.String)function.GetProperty(pAttributeExpectedException, "ExpectedMessage");
if (pExpectedExceptionName != null)
{
System.Exception pTestEx = pEx;
while (pTestEx != null)
{
if (pTestEx.ToString().StartsWith(pExpectedExceptionName))
{
if ((pExpectedMessage == null) || (pTestEx.Message.CompareTo(pExpectedMessage) == 0))
{
return true;
}
}
pTestEx = pTestEx.InnerException;
}
}
}
}
}
return false;
}
示例2: GetExpectedExceptionType
private Type GetExpectedExceptionType(Function function, Attribute pAttributeExpectedException)
{
System.Type result = function.GetProperty(pAttributeExpectedException, "ExpectedException") as System.Type;
if (result != null)
return result;
string name = function.GetProperty(pAttributeExpectedException, "ExpectedExceptionName") as string;
if (name != null)
{
result = Type.GetType(name);
}
return result;
}