當前位置: 首頁>>代碼示例>>C#>>正文


C# FaultException.GetType方法代碼示例

本文整理匯總了C#中System.ServiceModel.FaultException.GetType方法的典型用法代碼示例。如果您正苦於以下問題:C# FaultException.GetType方法的具體用法?C# FaultException.GetType怎麽用?C# FaultException.GetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ServiceModel.FaultException的用法示例。


在下文中一共展示了FaultException.GetType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ServiceFault

 public ServiceFault(FaultException<ServiceFault> sf)
 {
     this.Exception = sf.Detail.GetType().Name;
     this.Type = sf.GetType().FullName;
     this.Message = sf.Detail.Message;
     this.StackTrace = sf.Detail.StackTrace;
     this.InnerException = sf.Detail.InnerException;
     if (sf.Detail.ValidationErrors != null) this.ValidationErrors = sf.Detail.ValidationErrors;
 }
開發者ID:jserna-arl,項目名稱:LIMSv2,代碼行數:9,代碼來源:ServiceFault.cs

示例2: ToException

        public System.Exception ToException(FaultException faultException)
        {
            var type = faultException.GetType();
            if (!type.IsGenericType)
                return new System.Exception(faultException.Message);

            var property = type.GetProperty("Detail");
            if (property == null || !property.PropertyType.IsSubclassOf(typeof(TranslatableFault)))
                return new System.Exception(faultException.Message);

            var fault = (TranslatableFault)property.GetValue(faultException, null);
            return fault.ToException();
        }
開發者ID:ninjaferret,項目名稱:NinjaFerret.Wcf,代碼行數:13,代碼來源:ExceptionTranslator.cs

示例3: TestToString

		public void TestToString ()
		{
			FaultException<int> e = new FaultException<int> (0);			
			Assert.AreEqual (
				String.Format ("{0}: {1} (Fault Detail is equal to {2}).", e.GetType (), e.Message, e.Detail),
				e.ToString ());
		}
開發者ID:nickchal,項目名稱:pash,代碼行數:7,代碼來源:FaultExceptionTest.cs

示例4: HandleFaultException

        public static void HandleFaultException(FaultException ex)
        {
            var msgString = "";

            var exType = ex.GetType();
            var prop = exType.GetProperty("Detail");
            var faultDetail = prop.GetValue(ex, null);
            var faultType = faultDetail.GetType();

            // Secure Token Service (STS) Faults
            if (faultType.IsInstanceOfType(new AuthenticationFault())) // 406
            {
                var authenticationFault = faultDetail as AuthenticationFault;
                msgString = msgString + "***Fault Exception: AuthenticationFault!***\n";
                msgString = msgString + "    ErrorId:     " + authenticationFault.ErrorID + "\n";
                msgString = msgString + "    Operation:   " + authenticationFault.Operation + "\n";
                msgString = msgString + "    ProblemType: " + authenticationFault.ProblemType + "\n";
            }
            if (faultType.IsInstanceOfType(new STSUnavailableFault())) // 412
            {
                var stsUnavailableFault = faultDetail as STSUnavailableFault;
                msgString = msgString + "***Fault Exception: STSUnavailableFault!***\n";
                msgString = msgString + "    ErrorId:     " + stsUnavailableFault.ErrorID + "\n";
                msgString = msgString + "    Operation:   " + stsUnavailableFault.Operation + "\n";
                msgString = msgString + "    ProblemType: " + stsUnavailableFault.ProblemType + "\n";
            }
            if (faultType.IsInstanceOfType(new AuthorizationFault())) // 413
            {
                var authorizationFault = faultDetail as AuthorizationFault;
                msgString = msgString + "***Fault Exception: AuthorizationFault!***\n";
                msgString = msgString + "    ErrorId:     " + authorizationFault.ErrorID + "\n";
                msgString = msgString + "    Operation:   " + authorizationFault.Operation + "\n";
                msgString = msgString + "    ProblemType: " + authorizationFault.ProblemType + "\n";
            }
            if (faultType.IsInstanceOfType(new ExpiredTokenFault())) // 5000
            {
                var expiredTokenFault = faultDetail as ExpiredTokenFault;
                msgString = msgString + "***Fault Exception: ExpiredTokenFault!***\n";
                msgString = msgString + "    ErrorId:     " + expiredTokenFault.ErrorID + "\n";
                msgString = msgString + "    Operation:   " + expiredTokenFault.Operation + "\n";
                msgString = msgString + "    ProblemType: " + expiredTokenFault.ProblemType + "\n";
            }
            if (faultType.IsInstanceOfType(new InvalidTokenFault())) // 5005
            {
                var invalidTokenFault = faultDetail as InvalidTokenFault;
                msgString = msgString + "***Fault Exception: InvalidTokenFault!***\n";
                msgString = msgString + "    ErrorId:     " + invalidTokenFault.ErrorID + "\n";
                msgString = msgString + "    Operation:   " + invalidTokenFault.Operation + "\n";
                msgString = msgString + "    ProblemType: " + invalidTokenFault.ProblemType + "\n";
            }
            // Service Information Service Faults
            if (faultType.IsInstanceOfType(new CWSFault())) // 207
            {
                var cwsFault = faultDetail as CWSFault;
                msgString = msgString + "***Fault Exception: CWSFault!***\n";
                msgString = msgString + "    ErrorId:     " + cwsFault.ErrorID + "\n";
                msgString = msgString + "    Operation:   " + cwsFault.Operation + "\n";
                msgString = msgString + "    ProblemType: " + cwsFault.ProblemType + "\n";
            }
            if (faultType.IsInstanceOfType(new CWSValidationResultFault())) // 225
            {
                var cwsValidationResultFault = faultDetail as CWSValidationResultFault;
                msgString = msgString + "***Fault Exception: CWSValidationResultFault!***\n";
                msgString = msgString + "    ErrorId:     " + cwsValidationResultFault.ErrorID + "\n";
                msgString = msgString + "    Operation:   " + cwsValidationResultFault.Operation + "\n";
                msgString = msgString + "    ProblemType: " + cwsValidationResultFault.ProblemType + "\n";
                msgString = msgString + "    Error Count: " + cwsValidationResultFault.Errors.Count() + "\n";
                foreach (var error in cwsValidationResultFault.Errors)
                {
                    msgString = msgString + "        Location: " + error.RuleLocationKey + " ---- Message : " + error.RuleMessage + "\n";
                }
            }
            if (faultType.IsInstanceOfType(new SystemFault())) // 401
            {
                var cwsFault = faultDetail as CWSFault;
                msgString = msgString + "***Fault Exception: CWSFault!***\n";
                msgString = msgString + "    ErrorId:     " + cwsFault.ErrorID + "\n";
                msgString = msgString + "    Operation:   " + cwsFault.Operation + "\n";
                msgString = msgString + "    ProblemType: " + cwsFault.ProblemType + "\n";
            }
            if (faultType.IsInstanceOfType(new ClaimNotFoundFault())) // 415
            {
                var claimNotFoundFault = faultDetail as ClaimNotFoundFault;
                msgString = msgString + "***Fault Exception: ClaimNotFoundFault!***\n";
                msgString = msgString + "    ErrorId:     " + claimNotFoundFault.ErrorID + "\n";
                msgString = msgString + "    Operation:   " + claimNotFoundFault.Operation + "\n";
                msgString = msgString + "    ProblemType: " + claimNotFoundFault.ProblemType + "\n";
            }
            if (faultType.IsInstanceOfType(new RelyingPartyNotAssociatedToSecurityDomainFault())) // 450
            {
                var fault = faultDetail as RelyingPartyNotAssociatedToSecurityDomainFault;
                msgString = msgString + "***Fault Exception: RelyingPartyNotAssociatedToSecurityDomainFault!***\n";
                msgString = msgString + "    ErrorId:     " + fault.ErrorID + "\n";
                msgString = msgString + "    Operation:   " + fault.Operation + "\n";
                msgString = msgString + "    ProblemType: " + fault.ProblemType + "\n";
            }
            if (faultType.IsInstanceOfType(new CWSServiceInformationUnavailableFault())) // 9998
            {
                var fault = faultDetail as CWSServiceInformationUnavailableFault;
                msgString = msgString + "***Fault Exception: CWSServiceInformationUnavailableFault!***\n";
//.........這裏部分代碼省略.........
開發者ID:kolomeyera,項目名稱:Commerce-Web-Services-CommandLine-CSharp,代碼行數:101,代碼來源:SoapFaultHandler.cs


注:本文中的System.ServiceModel.FaultException.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。