Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Dispatcher / ErrorBehavior.cs / 1 / ErrorBehavior.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Dispatcher { using System; using System.ServiceModel.Channels; using System.ServiceModel; using System.Collections.ObjectModel; using System.Collections.Generic; using System.ServiceModel.Diagnostics; class ErrorBehavior { IErrorHandler[] handlers; bool debug; bool isOnServer; MessageVersion messageVersion; internal ErrorBehavior(ChannelDispatcher channelDispatcher) { this.handlers = EmptyArray.ToArray(channelDispatcher.ErrorHandlers); this.debug = channelDispatcher.IncludeExceptionDetailInFaults; this.isOnServer = channelDispatcher.IsOnServer; this.messageVersion = channelDispatcher.MessageVersion; } void InitializeFault(ref MessageRpc rpc) { Exception error = rpc.Error; FaultException fault = error as FaultException; if (fault != null) { string action; MessageFault messageFault = rpc.Operation.FaultFormatter.Serialize(fault, out action); if (action == null) action = rpc.RequestVersion.Addressing.DefaultFaultAction; if (messageFault != null) rpc.FaultInfo.Fault = Message.CreateMessage(rpc.RequestVersion, messageFault, action); } } internal IErrorHandler[] Handlers { get { return handlers; } } internal void ProvideMessageFault(ref MessageRpc rpc) { if (rpc.Error != null) { ProvideMessageFaultCore(ref rpc); } } void ProvideMessageFaultCore(ref MessageRpc rpc) { if (this.messageVersion != rpc.RequestVersion) { DiagnosticUtility.DebugAssert("System.ServiceModel.Dispatcher.ErrorBehavior.ProvideMessageFaultCore(): (this.messageVersion != rpc.RequestVersion)"); } this.InitializeFault(ref rpc); this.ProvideFault(rpc.Error, rpc.Channel.GetProperty (), ref rpc.FaultInfo); this.ProvideMessageFaultCoreCoda(ref rpc); } void ProvideFaultOfLastResort(Exception error, ref ErrorHandlerFaultInfo faultInfo) { if (faultInfo.Fault == null) { FaultCode code = new FaultCode(FaultCodeConstants.Codes.InternalServiceFault, FaultCodeConstants.Namespaces.NetDispatch); code = FaultCode.CreateReceiverFaultCode(code); string action = FaultCodeConstants.Actions.NetDispatcher; MessageFault fault; if (this.debug) { faultInfo.DefaultFaultAction = action; fault = MessageFault.CreateFault(code, new FaultReason(error.Message), new ExceptionDetail(error)); } else { string reason = this.isOnServer ? SR.GetString(SR.SFxInternalServerError) : SR.GetString(SR.SFxInternalCallbackError); fault = MessageFault.CreateFault(code, new FaultReason(reason)); } faultInfo.IsConsideredUnhandled = true; faultInfo.Fault = Message.CreateMessage(this.messageVersion, fault, action); } } void ProvideMessageFaultCoreCoda(ref MessageRpc rpc) { if (rpc.FaultInfo.Fault.Headers.Action == null) { rpc.FaultInfo.Fault.Headers.Action = rpc.RequestVersion.Addressing.DefaultFaultAction; } rpc.Reply = rpc.FaultInfo.Fault; } internal void ProvideOnlyFaultOfLastResort(ref MessageRpc rpc) { this.ProvideFaultOfLastResort(rpc.Error, ref rpc.FaultInfo); this.ProvideMessageFaultCoreCoda(ref rpc); } internal void ProvideFault(Exception e, FaultConverter faultConverter, ref ErrorHandlerFaultInfo faultInfo) { ProvideWellKnownFault(e, faultConverter, ref faultInfo); for (int i=0; i
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EventLog.cs
- CollectionExtensions.cs
- SQLDateTimeStorage.cs
- followingsibling.cs
- Columns.cs
- WindowsGraphicsWrapper.cs
- SqlDataReaderSmi.cs
- CommandID.cs
- EntityAdapter.cs
- ApplicationDirectory.cs
- SerialErrors.cs
- CacheModeConverter.cs
- FlowDocumentView.cs
- Stroke.cs
- safelinkcollection.cs
- SmtpFailedRecipientsException.cs
- UIElement3DAutomationPeer.cs
- MostlySingletonList.cs
- _FtpControlStream.cs
- ColorConvertedBitmapExtension.cs
- PointAnimation.cs
- LicenseContext.cs
- XmlName.cs
- MultiSelectRootGridEntry.cs
- ResponseBodyWriter.cs
- PageWrapper.cs
- IsolatedStorage.cs
- Int64.cs
- Pool.cs
- RegistrationServices.cs
- OracleInternalConnection.cs
- InfoCardClaim.cs
- TableLayoutSettings.cs
- ColumnHeader.cs
- XmlSerializer.cs
- DataGridViewRowCancelEventArgs.cs
- TagNameToTypeMapper.cs
- ValidationEventArgs.cs
- ConstraintManager.cs
- HttpDebugHandler.cs
- __Filters.cs
- LinqDataSourceDeleteEventArgs.cs
- cryptoapiTransform.cs
- ResourcePermissionBaseEntry.cs
- FreezableDefaultValueFactory.cs
- StreamResourceInfo.cs
- ManifestResourceInfo.cs
- SafeNativeMethods.cs
- HtmlTableRow.cs
- OleDbCommandBuilder.cs
- SafeRightsManagementEnvironmentHandle.cs
- Variable.cs
- BamlRecords.cs
- RIPEMD160.cs
- DbConnectionPoolIdentity.cs
- InkSerializer.cs
- DbProviderFactory.cs
- Models.cs
- EntityParameterCollection.cs
- Vector3DConverter.cs
- XPathParser.cs
- Input.cs
- SiteMapNodeCollection.cs
- ModuleConfigurationInfo.cs
- XmlSchemaAppInfo.cs
- BypassElementCollection.cs
- StrongNameUtility.cs
- FormViewPagerRow.cs
- SqlDataSource.cs
- Matrix3D.cs
- Base64Encoder.cs
- ColumnWidthChangingEvent.cs
- CompositeDataBoundControl.cs
- SetterBaseCollection.cs
- HMACRIPEMD160.cs
- LifetimeServices.cs
- ConversionValidationRule.cs
- AnyAllSearchOperator.cs
- DispatchWrapper.cs
- Pen.cs
- TranslateTransform3D.cs
- TraceProvider.cs
- UpdatePanelTriggerCollection.cs
- GeometryCombineModeValidation.cs
- LinkLabel.cs
- XmlSchemaProviderAttribute.cs
- ObjectDataSourceDisposingEventArgs.cs
- GridView.cs
- QilXmlReader.cs
- HttpMethodConstraint.cs
- RuntimeResourceSet.cs
- AccessControlList.cs
- XmlObjectSerializer.cs
- DatePickerAutomationPeer.cs
- entityreference_tresulttype.cs
- CompModHelpers.cs
- NullEntityWrapper.cs
- DrawTreeNodeEventArgs.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- messageonlyhwndwrapper.cs