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
- ServiceReference.cs
- TextRunProperties.cs
- GridLength.cs
- ThreadStaticAttribute.cs
- PngBitmapEncoder.cs
- TemplateEditingService.cs
- GeneralTransform3DCollection.cs
- AttachedPropertyDescriptor.cs
- FontStretches.cs
- PcmConverter.cs
- TcpHostedTransportConfiguration.cs
- HealthMonitoringSection.cs
- LockedAssemblyCache.cs
- ListViewCancelEventArgs.cs
- AttachedPropertiesService.cs
- PackWebRequestFactory.cs
- SqlErrorCollection.cs
- Literal.cs
- HtmlTableCellCollection.cs
- HttpStaticObjectsCollectionWrapper.cs
- XmlRawWriterWrapper.cs
- RadioButton.cs
- SizeChangedEventArgs.cs
- DataList.cs
- CaseInsensitiveOrdinalStringComparer.cs
- SelectingProviderEventArgs.cs
- WaitForChangedResult.cs
- PointLightBase.cs
- RequestCache.cs
- ApplicationId.cs
- TableRow.cs
- NativeWindow.cs
- BypassElementCollection.cs
- ToolBarButton.cs
- StringValidator.cs
- _LoggingObject.cs
- Message.cs
- FixedPageAutomationPeer.cs
- NameValueCollection.cs
- DocumentSequenceHighlightLayer.cs
- CompletionBookmark.cs
- LoginView.cs
- InputReportEventArgs.cs
- FixedSOMPage.cs
- _HeaderInfoTable.cs
- _ContextAwareResult.cs
- FontDriver.cs
- invalidudtexception.cs
- TypeHelper.cs
- SystemInformation.cs
- ActivityCollectionMarkupSerializer.cs
- DateTimeSerializationSection.cs
- BamlRecords.cs
- RemotingAttributes.cs
- XsdDuration.cs
- MulticastOption.cs
- XmlQueryType.cs
- StringResourceManager.cs
- CodeIdentifiers.cs
- CodeCompileUnit.cs
- HttpPostClientProtocol.cs
- BitmapFrameDecode.cs
- AuthStoreRoleProvider.cs
- ToolStripPanelSelectionBehavior.cs
- KeyValueConfigurationElement.cs
- Condition.cs
- SchemaNotation.cs
- HttpListenerPrefixCollection.cs
- TripleDESCryptoServiceProvider.cs
- CodeStatement.cs
- ElementsClipboardData.cs
- EncodingFallbackAwareXmlTextWriter.cs
- HandleExceptionArgs.cs
- BuildResultCache.cs
- MulticastDelegate.cs
- LocatorManager.cs
- ReturnEventArgs.cs
- SetStoryboardSpeedRatio.cs
- TableStyle.cs
- SplineKeyFrames.cs
- webproxy.cs
- TreeNodeEventArgs.cs
- SqlGenerator.cs
- UrlMappingsSection.cs
- Pool.cs
- HttpWebRequest.cs
- util.cs
- ISAPIApplicationHost.cs
- WebPartDisplayModeEventArgs.cs
- SyndicationDeserializer.cs
- QilFunction.cs
- RequiredAttributeAttribute.cs
- ComplexObject.cs
- StorageEntityContainerMapping.cs
- DataGridViewRowCollection.cs
- SHA512.cs
- mda.cs
- Ipv6Element.cs
- QueueAccessMode.cs
- DocobjHost.cs