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
- DomainUpDown.cs
- GenericParameterDataContract.cs
- ItemsControlAutomationPeer.cs
- DoubleAnimationBase.cs
- MergeEnumerator.cs
- ButtonBaseAutomationPeer.cs
- TextAutomationPeer.cs
- MetaTable.cs
- PlaceHolder.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- CalendarDateRangeChangingEventArgs.cs
- WebPartUserCapability.cs
- EdmFunction.cs
- DefaultPerformanceCounters.cs
- PenCursorManager.cs
- XmlObjectSerializerReadContextComplexJson.cs
- CertificateManager.cs
- TextFragmentEngine.cs
- WsatTransactionHeader.cs
- TextBreakpoint.cs
- ToolboxComponentsCreatedEventArgs.cs
- LineUtil.cs
- EditorPartChrome.cs
- ServiceDescription.cs
- DataRowChangeEvent.cs
- TreeWalker.cs
- SqlDataSourceSelectingEventArgs.cs
- MemoryResponseElement.cs
- ScrollProperties.cs
- TextTreeNode.cs
- CompositeCollectionView.cs
- XmlChildNodes.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- LineGeometry.cs
- MetabaseReader.cs
- DependencyPropertyAttribute.cs
- QueryCacheKey.cs
- MexTcpBindingCollectionElement.cs
- MatrixCamera.cs
- SchemaMapping.cs
- BindToObject.cs
- TextDecoration.cs
- Timeline.cs
- ListItem.cs
- Matrix.cs
- Pen.cs
- StructureChangedEventArgs.cs
- GetPageCompletedEventArgs.cs
- CodePageUtils.cs
- CacheChildrenQuery.cs
- ComponentManagerBroker.cs
- EventWaitHandleSecurity.cs
- DelegatedStream.cs
- ModuleConfigurationInfo.cs
- CaseCqlBlock.cs
- DateTimeConverter.cs
- DeviceContext.cs
- PrintDocument.cs
- RadioButtonList.cs
- StopRoutingHandler.cs
- QueryCacheKey.cs
- ScrollProviderWrapper.cs
- BufferedMessageData.cs
- QueryPageSettingsEventArgs.cs
- WebHeaderCollection.cs
- DesignerForm.cs
- WSTrust.cs
- RoleManagerSection.cs
- XmlName.cs
- ConfigXmlText.cs
- ContentPosition.cs
- MessagePartSpecification.cs
- CodeExpressionStatement.cs
- GestureRecognizer.cs
- TypeResolver.cs
- CommandLineParser.cs
- CategoryGridEntry.cs
- GeometryValueSerializer.cs
- EventLogEntryCollection.cs
- XmlBinaryReaderSession.cs
- ByteAnimationBase.cs
- SystemKeyConverter.cs
- ColumnPropertiesGroup.cs
- SqlCacheDependencyDatabaseCollection.cs
- DefaultHttpHandler.cs
- ToolStripDropDownButton.cs
- DBProviderConfigurationHandler.cs
- DependencyPropertyChangedEventArgs.cs
- WsatTransactionFormatter.cs
- ListViewItemSelectionChangedEvent.cs
- Module.cs
- XmlNotation.cs
- XamlSerializerUtil.cs
- ServiceContractAttribute.cs
- Privilege.cs
- OdbcError.cs
- Logging.cs
- ComplusTypeValidator.cs
- DbDeleteCommandTree.cs
- MetadataItemEmitter.cs