当前位置: 首页>>代码示例>>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;未经允许,请勿转载。