當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。