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


C# Exception.NotNull方法代码示例

本文整理汇总了C#中System.Exception.NotNull方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.NotNull方法的具体用法?C# Exception.NotNull怎么用?C# Exception.NotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Exception的用法示例。


在下文中一共展示了Exception.NotNull方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Handle

        /// <summary>
        /// Handles all exceptions in the chain
        /// </summary>
        /// <param name="exceptionToHandle">The exception to handle</param>
        /// <returns>Whether or not a rethrow is recommended</returns>
        public bool Handle(Exception exceptionToHandle)
        {
            exceptionToHandle.NotNull(nameof(exceptionToHandle));

            return RethrowRecommended(
                ExecuteHandlerChain(exceptionToHandle, Guid.NewGuid()));
        }
开发者ID:c4rm4x,项目名称:C4rm4x.WebApi,代码行数:12,代码来源:ExceptionPolicyEntry.cs

示例2: MethodReturn

        /// <summary>
        /// Parameterized constructor.
        /// </summary>
        public MethodReturn(IMethodInvocation originalInvocation, Exception exception)
        {
            originalInvocation.NotNull("originalInvocation");
            exception.NotNull("exception");

            this.InvocationContext = originalInvocation.InvocationContext;
            this.Exception = exception;
            this.Outputs = new ParameterCollection(new object[0], new ParameterInfo[0], delegate { return false; });
        }
开发者ID:imyounghan,项目名称:thinklib,代码行数:12,代码来源:MethodReturn.cs

示例3: HandleException

        /// <summary>
        /// Checks if there is a policy entry that matches
        /// the type of the specified exception,
        /// and if so, invokes the handlers associated with that entry
        /// </summary>
        /// <param name="exceptionToHandle">The exception to handle</param>
        /// <returns>True when rethrowing an exception is recommended</returns>
        public bool HandleException(Exception exceptionToHandle)
        {
            exceptionToHandle.NotNull(nameof(exceptionToHandle));

            var entry = GetPolicyEntry(exceptionToHandle);

            return entry.IsNull()
                ? true
                : entry.Handle(exceptionToHandle);
        }
开发者ID:c4rm4x,项目名称:C4rm4x.WebApi,代码行数:17,代码来源:ExceptionPolicyDefinition.cs

示例4: HandleException

        /// <summary>
        /// Handles the specified exception object according to the rules configured for policyName
        /// </summary>
        /// <param name="exceptionToHandle">The exception to handle</param>
        /// <param name="policyName">The name of the policy to handle</param>        
        /// <returns>True if rethrowing an exception is recommended; otherwise, false</returns>
        /// <example>
        /// The following code shows the usage of the 
        /// exception handling framework.
        /// <code>
        ///    try
        ///    {
        ///        DoWork();
        ///    }
        ///    catch (Exception e)
        ///    {
        ///        if (exceptionManager.HandleException(e, name)) throw;
        ///    }
        /// </code>
        /// </example>
        public bool HandleException(
            Exception exceptionToHandle,
            string policyName = "default")
        {
            exceptionToHandle.NotNull(nameof(exceptionToHandle));
            policyName.NotNullOrEmpty(nameof(policyName));

            IExceptionPolicyDefinition exceptionPolicy;

            if (!_exceptionPolicies.TryGetValue(policyName, out exceptionPolicy))
                throw new InvalidOperationException("Exception policy not found");

            return exceptionPolicy.HandleException(exceptionToHandle);
        }
开发者ID:c4rm4x,项目名称:C4rm4x.WebApi,代码行数:34,代码来源:ExceptionManager.cs

示例5: HandleException

        private static bool HandleException(
            Exception exceptionToHandle,
            string policyName = "default")
        {
            exceptionToHandle.NotNull(nameof(exceptionToHandle));
            policyName.NotNullOrEmpty(nameof(policyName));

            return ExceptionManager
                .HandleException(exceptionToHandle, policyName);
        }
开发者ID:c4rm4x,项目名称:C4rm4x.WebApi,代码行数:10,代码来源:ExceptionPolicy.cs


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