当前位置: 首页>>代码示例>>C#>>正文


C# NotSupportedException.GetType方法代码示例

本文整理汇总了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);
        }
开发者ID:roryprimrose,项目名称:ModelBuilder,代码行数:50,代码来源:DefaultExecuteStrategy.cs

示例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);
        }
开发者ID:sergeyDyadenchuk,项目名称:Testing,代码行数:33,代码来源:TextTests.cs


注:本文中的System.NotSupportedException.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。