本文整理汇总了C#中System.NotSupportedException.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# NotSupportedException.GetType方法的具体用法?C# NotSupportedException.GetType怎么用?C# NotSupportedException.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.NotSupportedException
的用法示例。
在下文中一共展示了NotSupportedException.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildFailureException
private Exception BuildFailureException(Type type, string referenceName, object context)
{
string message;
if (string.IsNullOrWhiteSpace(referenceName) == false)
{
if (context != null)
{
message = string.Format(
CultureInfo.CurrentCulture,
Resources.NoMatchingCreatorOrGeneratorFoundWithNameAndContext,
type.FullName,
referenceName,
context.GetType().FullName);
}
else
{
message = string.Format(
CultureInfo.CurrentCulture,
Resources.NoMatchingCreatorOrGeneratorFoundWithName,
type.FullName,
referenceName);
}
}
else
{
message = string.Format(
CultureInfo.CurrentCulture,
Resources.NoMatchingCreatorOrGeneratorFound,
type.FullName);
}
var ex = new NotSupportedException(message);
Log.BuildFailure(ex);
const string MessageFormat =
"Failed to create instance of type {0}, {1}: {2}{3}{3}At the time of the failure, the build log was:{3}{3}{4}";
var buildLog = Log.Output;
var failureMessage = string.Format(
CultureInfo.CurrentCulture,
MessageFormat,
type.FullName,
ex.GetType().Name,
ex.Message,
Environment.NewLine,
buildLog);
return new BuildException(failureMessage, type, referenceName, context, buildLog, ex);
}
示例2: Range_RemoveFromSelection
//---------------------------------------------------------------------------
// Wrapper for TextPatternRange.RemoveFromSelection Method
//---------------------------------------------------------------------------
internal void Range_RemoveFromSelection(TextPatternRange callingRange, Type expectedException, CheckType checkType)
{
string call = "TextPatternRange.RemoveFromSelection()";
Comment("---Calling " + call);
if (callingRange == null)
throw new ArgumentNullException(call + " requires non-NULL TextPatterncallingRange");
try
{
callingRange.RemoveFromSelection();
}
catch (Exception actualException)
{
if (Library.IsCriticalException(actualException))
throw;
// Bug 1746355: Throw "NotSupported" from TextPattern methods that...um...aren't supported
if ((actualException is NotSupportedException) && (_frameworkId == "wpf"))
{
NotSupportedException nse = new NotSupportedException();
TestException(nse.GetType(), actualException, call, checkType);
}
else
TestException(expectedException, actualException, call, checkType);
return;
}
TestNoExceptionQuiet(expectedException, call, checkType);
}