Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Dispatcher / XmlSerializerFaultFormatter.cs / 2 / XmlSerializerFaultFormatter.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- using System; using System.Xml; using System.Text; using System.Reflection; using System.Diagnostics; using System.Xml.Serialization; using System.Runtime.Serialization; using System.Collections.Generic; using System.ServiceModel.Channels; using System.ServiceModel.Description; namespace System.ServiceModel.Dispatcher { class XmlSerializerFaultFormatter : FaultFormatter { SynchronizedCollectionxmlSerializerFaultContractInfos; internal XmlSerializerFaultFormatter(Type[] detailTypes, SynchronizedCollection xmlSerializerFaultContractInfos) : base(detailTypes) { Initialize(xmlSerializerFaultContractInfos); } internal XmlSerializerFaultFormatter(SynchronizedCollection faultContractInfoCollection, SynchronizedCollection xmlSerializerFaultContractInfos) : base(faultContractInfoCollection) { Initialize(xmlSerializerFaultContractInfos); } void Initialize(SynchronizedCollection xmlSerializerFaultContractInfos) { if (xmlSerializerFaultContractInfos == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlSerializerFaultContractInfos"); } this.xmlSerializerFaultContractInfos = xmlSerializerFaultContractInfos; } protected override XmlObjectSerializer GetSerializer(Type detailType, string faultExceptionAction, out string action) { action = faultExceptionAction; XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo faultInfo = null; for (int i = 0; i < this.xmlSerializerFaultContractInfos.Count; i++) { if (this.xmlSerializerFaultContractInfos[i].FaultContractInfo.Detail == detailType) { faultInfo = this.xmlSerializerFaultContractInfos[i]; break; } } if (faultInfo != null) { if (action == null) action = faultInfo.FaultContractInfo.Action; return faultInfo.Serializer; } else return new XmlSerializerObjectSerializer(detailType); } protected override FaultException CreateFaultException(MessageFault messageFault, string action) { IList faultInfos; if (action != null) { faultInfos = new List (); for (int i = 0; i < this.xmlSerializerFaultContractInfos.Count; i++) { if (this.xmlSerializerFaultContractInfos[i].FaultContractInfo.Action == action || this.xmlSerializerFaultContractInfos[i].FaultContractInfo.Action == MessageHeaders.WildcardAction) { faultInfos.Add(this.xmlSerializerFaultContractInfos[i]); } } } else { faultInfos = this.xmlSerializerFaultContractInfos; } Type detailType = null; object detailObj = null; for (int i = 0; i < faultInfos.Count; i++) { XmlSerializerOperationBehavior.Reflector.XmlSerializerFaultContractInfo faultInfo = faultInfos[i]; XmlDictionaryReader detailReader = messageFault.GetReaderAtDetailContents(); XmlObjectSerializer serializer = faultInfo.Serializer; if (serializer.IsStartObject(detailReader)) { detailType = faultInfo.FaultContractInfo.Detail; try { detailObj = serializer.ReadObject(detailReader); FaultException faultException = CreateFaultException(messageFault, action, detailObj, detailType, detailReader); if (faultException != null) return faultException; } catch (SerializationException) { } } } return new FaultException(messageFault, action); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RightsManagementEncryptedStream.cs
- TabControlAutomationPeer.cs
- RuleAttributes.cs
- Variable.cs
- DynamicILGenerator.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- DataBoundControl.cs
- ValidatedMobileControlConverter.cs
- AuthenticateEventArgs.cs
- SoapParser.cs
- TextMessageEncoder.cs
- DataGridViewRowCollection.cs
- CharEntityEncoderFallback.cs
- RelationshipEndCollection.cs
- DataShape.cs
- SecurityHelper.cs
- ChangeBlockUndoRecord.cs
- HTTPNotFoundHandler.cs
- AttributeData.cs
- NavigationEventArgs.cs
- TraceLog.cs
- PrimitiveType.cs
- GeneralTransform2DTo3DTo2D.cs
- WebHeaderCollection.cs
- DesignerActionListCollection.cs
- DataGridViewCellCollection.cs
- ProgressChangedEventArgs.cs
- PerformanceCountersElement.cs
- WorkflowServiceHostFactory.cs
- SessionIDManager.cs
- TemplateKey.cs
- FixedSOMTableRow.cs
- SafeBitVector32.cs
- CanExecuteRoutedEventArgs.cs
- LocatorPart.cs
- DetailsViewInsertedEventArgs.cs
- ResourceFallbackManager.cs
- MsmqIntegrationElement.cs
- CanonicalFontFamilyReference.cs
- InvalidPropValue.cs
- DelegateSerializationHolder.cs
- ByteArrayHelperWithString.cs
- ExternalFile.cs
- TypeLibConverter.cs
- PlainXmlWriter.cs
- EmptyEnumerator.cs
- RestHandler.cs
- ComboBox.cs
- FixedSOMGroup.cs
- X509SecurityTokenProvider.cs
- CheckBoxBaseAdapter.cs
- Image.cs
- ComponentTray.cs
- HttpModuleCollection.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- StringHelper.cs
- ReadWriteObjectLock.cs
- CounterSample.cs
- BitmapEffectRenderDataResource.cs
- SettingsPropertyValue.cs
- ScrollData.cs
- XPathDescendantIterator.cs
- Timeline.cs
- PenContext.cs
- Stack.cs
- WizardStepBase.cs
- FollowerQueueCreator.cs
- XmlValueConverter.cs
- objectquery_tresulttype.cs
- GeneralTransform3DGroup.cs
- XPathNavigatorKeyComparer.cs
- DoubleAnimationUsingKeyFrames.cs
- TreeNodeStyleCollection.cs
- AuthenticationManager.cs
- HiddenFieldPageStatePersister.cs
- LinqDataSourceHelper.cs
- UInt64Converter.cs
- ParserContext.cs
- PageStatePersister.cs
- BulletChrome.cs
- MasterPageBuildProvider.cs
- SqlBinder.cs
- CodeTypeDelegate.cs
- KeyInterop.cs
- Aggregates.cs
- XPathScanner.cs
- AdapterSwitches.cs
- SQLBinary.cs
- GiveFeedbackEvent.cs
- GZipUtils.cs
- OleDbErrorCollection.cs
- DataGridViewDataErrorEventArgs.cs
- _AcceptOverlappedAsyncResult.cs
- AutomationPattern.cs
- UInt64Converter.cs
- DesignerSerializerAttribute.cs
- ContextConfiguration.cs
- ADRoleFactoryConfiguration.cs
- DoubleAnimationUsingPath.cs
- ProcessModuleCollection.cs