Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.WorkflowServices / System / ServiceModel / Dispatcher / DurableErrorHandler.cs / 1305376 / DurableErrorHandler.cs
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------
namespace System.ServiceModel.Dispatcher
{
using System.ServiceModel.Channels;
using System.Diagnostics.CodeAnalysis;
abstract class DurableErrorHandler : IErrorHandler
{
bool debug;
public DurableErrorHandler(bool debug)
{
this.debug = debug;
}
public static void CleanUpInstanceContextAtOperationCompletion()
{
if (OperationContext.Current == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR2.NoOperationContext));
}
DurableMessageDispatchInspector.SuppressContextOnReply(OperationContext.Current);
OperationContext.Current.InstanceContext.IncomingChannels.Clear();
}
public bool HandleError(Exception error)
{
return IsUserCodeException(error);
}
[SuppressMessage("Microsoft.Globalization", "CA1304")]
public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
{
if (fault == null && IsUserCodeException(error))
{
FaultCode code = new FaultCode(FaultCodeConstants.Codes.InternalServiceFault, FaultCodeConstants.Namespaces.NetDispatch);
code = FaultCode.CreateReceiverFaultCode(code);
string action = FaultCodeConstants.Actions.NetDispatcher;
MessageFault messageFault;
if (this.debug)
{
Exception toTrace = GetExceptionToTrace(error);
messageFault = MessageFault.CreateFault(code, new FaultReason(toTrace.Message), new ExceptionDetail(toTrace));
}
else
{
string reason = SR.GetString(SR.SFxInternalServerError);
messageFault = MessageFault.CreateFault(code, new FaultReason(reason));
}
fault = Message.CreateMessage(version, messageFault, action);
}
}
protected virtual Exception GetExceptionToTrace(Exception error)
{
return error;
}
protected abstract bool IsUserCodeException(Exception error);
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Logging.cs
- sqlinternaltransaction.cs
- CallbackValidator.cs
- DesignSurfaceServiceContainer.cs
- X509ServiceCertificateAuthentication.cs
- ObjectDataSourceView.cs
- OracleBoolean.cs
- ExitEventArgs.cs
- grammarelement.cs
- FixUpCollection.cs
- CodeAttachEventStatement.cs
- DocumentGrid.cs
- StrongNameKeyPair.cs
- SafeCryptContextHandle.cs
- NameScopePropertyAttribute.cs
- Matrix3D.cs
- ObjectListSelectEventArgs.cs
- Blend.cs
- VariableAction.cs
- ControlValuePropertyAttribute.cs
- OracleDateTime.cs
- BinHexDecoder.cs
- EntityParameter.cs
- ListChangedEventArgs.cs
- FrameworkContentElement.cs
- AcceleratedTokenAuthenticator.cs
- ObjectDataSourceDesigner.cs
- OptimizerPatterns.cs
- PointCollectionConverter.cs
- GenericEnumConverter.cs
- AuthorizationSection.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- CompilerHelpers.cs
- XhtmlTextWriter.cs
- DispatcherExceptionFilterEventArgs.cs
- WebBrowser.cs
- EncodingNLS.cs
- XPathDescendantIterator.cs
- CharAnimationBase.cs
- xmlsaver.cs
- BamlCollectionHolder.cs
- XamlSerializerUtil.cs
- oledbmetadatacolumnnames.cs
- Unit.cs
- AdRotator.cs
- SwitchAttribute.cs
- ApplicationDirectory.cs
- ByteConverter.cs
- PrinterResolution.cs
- ItemCheckedEvent.cs
- EntityContainer.cs
- CategoryEditor.cs
- ProcessHost.cs
- AndCondition.cs
- TransportElement.cs
- PlatformCulture.cs
- TableStyle.cs
- XpsImageSerializationService.cs
- QilSortKey.cs
- DEREncoding.cs
- SystemUdpStatistics.cs
- HandledEventArgs.cs
- HtmlValidationSummaryAdapter.cs
- Aes.cs
- querybuilder.cs
- OperationResponse.cs
- XmlIterators.cs
- GetCardDetailsRequest.cs
- MatrixTransform3D.cs
- AutomationIdentifier.cs
- ExternalException.cs
- RectangleConverter.cs
- DataSetSchema.cs
- WindowManager.cs
- SlipBehavior.cs
- EmptyElement.cs
- GridView.cs
- NoneExcludedImageIndexConverter.cs
- ListViewItem.cs
- ColorContextHelper.cs
- IsolationInterop.cs
- PointAnimationBase.cs
- TabItemWrapperAutomationPeer.cs
- BezierSegment.cs
- XamlStyleSerializer.cs
- Range.cs
- DrawingServices.cs
- Random.cs
- FormViewUpdateEventArgs.cs
- BamlResourceDeserializer.cs
- SerializationSectionGroup.cs
- ObjectCloneHelper.cs
- DataGridViewRowHeaderCell.cs
- DocumentPage.cs
- HelpInfo.cs
- PropertyGeneratedEventArgs.cs
- StatusBarAutomationPeer.cs
- ResourcePool.cs
- Mutex.cs
- InputMethodStateTypeInfo.cs