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
- OlePropertyStructs.cs
- AxHost.cs
- ObjectDataSourceDisposingEventArgs.cs
- Object.cs
- ReflectionTypeLoadException.cs
- PreviewKeyDownEventArgs.cs
- ChooseAction.cs
- XmlIncludeAttribute.cs
- ReadWriteObjectLock.cs
- CodeTypeDelegate.cs
- EnumBuilder.cs
- CompareInfo.cs
- WebPartConnectVerb.cs
- ShutDownListener.cs
- RegexMatch.cs
- OracleNumber.cs
- CryptographicAttribute.cs
- RelatedCurrencyManager.cs
- WsdlBuildProvider.cs
- InstanceNotFoundException.cs
- FunctionDetailsReader.cs
- XamlPointCollectionSerializer.cs
- ApplicationServiceHelper.cs
- CharacterMetrics.cs
- GridViewColumnHeaderAutomationPeer.cs
- ImageSourceConverter.cs
- EventLogPermissionHolder.cs
- ClosableStream.cs
- SpotLight.cs
- ISO2022Encoding.cs
- WSSecurityPolicy.cs
- DocumentGridContextMenu.cs
- Lasso.cs
- MethodToken.cs
- GridSplitterAutomationPeer.cs
- DataGridViewButtonColumn.cs
- DbProviderFactories.cs
- DataGridDesigner.cs
- StreamGeometryContext.cs
- SymLanguageType.cs
- DefaultTextStoreTextComposition.cs
- PermissionSet.cs
- Set.cs
- BinaryWriter.cs
- TypeSystem.cs
- bindurihelper.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- WizardSideBarListControlItem.cs
- ContentElement.cs
- updateconfighost.cs
- ComponentCollection.cs
- SendMailErrorEventArgs.cs
- SmtpClient.cs
- SemaphoreSlim.cs
- SQLChars.cs
- SerialReceived.cs
- TypedRowHandler.cs
- MarkupObject.cs
- FieldBuilder.cs
- Preprocessor.cs
- CompoundFileStorageReference.cs
- DispatcherEventArgs.cs
- CheckableControlBaseAdapter.cs
- CodeSubDirectory.cs
- UrlMapping.cs
- XmlParser.cs
- FixedPosition.cs
- LightweightCodeGenerator.cs
- RegexNode.cs
- MultiPartWriter.cs
- ViewValidator.cs
- GridViewEditEventArgs.cs
- HostProtectionPermission.cs
- DomainUpDown.cs
- XmlQueryContext.cs
- KeyInstance.cs
- KoreanLunisolarCalendar.cs
- FullTrustAssembly.cs
- XmlnsPrefixAttribute.cs
- BadImageFormatException.cs
- CodeCatchClause.cs
- FixedDocument.cs
- DispatcherTimer.cs
- SqlUtil.cs
- Page.cs
- ChannelServices.cs
- CodeTypeOfExpression.cs
- HashHelper.cs
- StorageModelBuildProvider.cs
- DataTableMappingCollection.cs
- ScriptManagerProxy.cs
- PtsCache.cs
- MsmqIntegrationMessagePool.cs
- ValidationEventArgs.cs
- InfoCardKeyedHashAlgorithm.cs
- CSharpCodeProvider.cs
- MarkupCompilePass2.cs
- SamlAttribute.cs
- CompiledXpathExpr.cs
- InvokeProviderWrapper.cs