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
- StateDesignerConnector.cs
- CheckBoxDesigner.cs
- DataViewListener.cs
- StreamReader.cs
- Win32KeyboardDevice.cs
- KeyTime.cs
- HtmlControlPersistable.cs
- InstanceOwner.cs
- XmlBoundElement.cs
- XmlDataLoader.cs
- StyleXamlParser.cs
- DES.cs
- DateTimePicker.cs
- PropertyBuilder.cs
- CqlGenerator.cs
- MetabaseServerConfig.cs
- PrimitiveType.cs
- ProviderUtil.cs
- FrameDimension.cs
- QuotedPairReader.cs
- CqlBlock.cs
- ValueQuery.cs
- DataGridColumnHeader.cs
- NumberSubstitution.cs
- EntityTemplateUserControl.cs
- AspNetPartialTrustHelpers.cs
- RuleAttributes.cs
- DocumentPage.cs
- Internal.cs
- ImageFormat.cs
- UriTemplateEquivalenceComparer.cs
- DelayedRegex.cs
- TemplateLookupAction.cs
- EntityContainer.cs
- ProfileModule.cs
- StronglyTypedResourceBuilder.cs
- ZoneLinkButton.cs
- BuildResult.cs
- WebRequest.cs
- SingleConverter.cs
- PreloadHost.cs
- SQLStringStorage.cs
- Font.cs
- IdentityModelDictionary.cs
- DataGridCaption.cs
- SchemaTypeEmitter.cs
- OciHandle.cs
- TextTreeInsertElementUndoUnit.cs
- XslUrlEditor.cs
- RepeaterItemCollection.cs
- Container.cs
- ScopedKnownTypes.cs
- TransmissionStrategy.cs
- ReadOnlyHierarchicalDataSource.cs
- FeedUtils.cs
- TypeNameParser.cs
- HostedImpersonationContext.cs
- SqlReorderer.cs
- DocumentViewerAutomationPeer.cs
- SplayTreeNode.cs
- Semaphore.cs
- SHA512.cs
- InfiniteTimeSpanConverter.cs
- WebServiceParameterData.cs
- PropertyCollection.cs
- Span.cs
- CallSiteBinder.cs
- CookieParameter.cs
- SqlNode.cs
- EntityObject.cs
- OutputCacheProfileCollection.cs
- Classification.cs
- SessionStateItemCollection.cs
- TextContainerHelper.cs
- ForceCopyBuildProvider.cs
- EmptyReadOnlyDictionaryInternal.cs
- RowsCopiedEventArgs.cs
- FormsAuthenticationEventArgs.cs
- ConditionalAttribute.cs
- ObjectCache.cs
- NavigationPropertyEmitter.cs
- XmlParserContext.cs
- SelectionPatternIdentifiers.cs
- EntitySetBaseCollection.cs
- TextAnchor.cs
- StateManagedCollection.cs
- WMICapabilities.cs
- _HTTPDateParse.cs
- NamespaceExpr.cs
- HandlerBase.cs
- ExpressionBuilder.cs
- CodeConstructor.cs
- ButtonFieldBase.cs
- WsiProfilesElement.cs
- metadatamappinghashervisitor.cs
- PcmConverter.cs
- HttpResponseHeader.cs
- Char.cs
- CompilerCollection.cs
- FixedTextContainer.cs