Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / NetFx35 / System.ServiceModel.Web / System / ServiceModel / Dispatcher / ContentTypeSettingClientMessageFormatter.cs / 1 / ContentTypeSettingClientMessageFormatter.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Dispatcher { using System.Collections; using System.ServiceModel.Channels; using System.ServiceModel; using System.ServiceModel.Description; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Reflection; using System.Xml; using System.ServiceModel.Diagnostics; using System.Net; using System.ServiceModel.Dispatcher; using System.ServiceModel.Web; class ContentTypeSettingClientMessageFormatter : IClientMessageFormatter { IClientMessageFormatter innerFormatter; string outgoingContentType; public ContentTypeSettingClientMessageFormatter(string outgoingContentType, IClientMessageFormatter innerFormatter) { if (outgoingContentType == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("outgoingContentType"); } if (innerFormatter == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("innerFormatter"); } this.outgoingContentType = outgoingContentType; this.innerFormatter = innerFormatter; } public object DeserializeReply(Message message, object[] parameters) { return this.innerFormatter.DeserializeReply(message, parameters); } public Message SerializeRequest(MessageVersion messageVersion, object[] parameters) { Message message = this.innerFormatter.SerializeRequest(messageVersion, parameters); if (message != null) { AddRequestContentTypeProperty(message, this.outgoingContentType); } return message; } static void AddRequestContentTypeProperty(Message message, string contentType) { if (message == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message"); } if (contentType == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contentType"); } if (OperationContext.Current != null && OperationContext.Current.HasOutgoingMessageProperties) { if (string.IsNullOrEmpty(WebOperationContext.Current.OutgoingRequest.ContentType)) { WebOperationContext.Current.OutgoingRequest.ContentType = contentType; } } else { object prop; message.Properties.TryGetValue(HttpRequestMessageProperty.Name, out prop); HttpRequestMessageProperty httpProperty; if (prop != null) { httpProperty = (HttpRequestMessageProperty) prop; } else { httpProperty = new HttpRequestMessageProperty(); message.Properties.Add(HttpRequestMessageProperty.Name, httpProperty); } if (string.IsNullOrEmpty(httpProperty.Headers[HttpRequestHeader.ContentType])) { httpProperty.Headers[HttpRequestHeader.ContentType] = contentType; } } } } } // 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
- CharEntityEncoderFallback.cs
- StorageComplexTypeMapping.cs
- Win32Exception.cs
- EventSetter.cs
- SharedDp.cs
- StreamWriter.cs
- DataSysAttribute.cs
- LineProperties.cs
- InstanceNotReadyException.cs
- HatchBrush.cs
- ImageConverter.cs
- WmlImageAdapter.cs
- UdpSocket.cs
- SweepDirectionValidation.cs
- MultiByteCodec.cs
- ResourceLoader.cs
- _Events.cs
- QueueProcessor.cs
- WindowsFormsHelpers.cs
- Propagator.cs
- MailWriter.cs
- FlowchartSizeFeature.cs
- DoubleLinkList.cs
- MiniConstructorInfo.cs
- BamlBinaryWriter.cs
- MetadataSerializer.cs
- Polygon.cs
- DashStyle.cs
- GroupDescription.cs
- OdbcStatementHandle.cs
- RequestCacheValidator.cs
- GridLength.cs
- Int64Storage.cs
- HyperLinkDesigner.cs
- ArithmeticException.cs
- EDesignUtil.cs
- DiagnosticsConfiguration.cs
- ModuleBuilder.cs
- URLEditor.cs
- ResourceAssociationSet.cs
- ParserContext.cs
- MetaModel.cs
- GroupBoxAutomationPeer.cs
- ActivityTrace.cs
- NewArrayExpression.cs
- ConnectorMovedEventArgs.cs
- MasterPage.cs
- ObjectAssociationEndMapping.cs
- WebAdminConfigurationHelper.cs
- QuaternionRotation3D.cs
- DataServiceHost.cs
- CompositeKey.cs
- ToolStripItemEventArgs.cs
- FastEncoderWindow.cs
- MiniConstructorInfo.cs
- MessageSmuggler.cs
- BamlStream.cs
- DataGridClipboardCellContent.cs
- RNGCryptoServiceProvider.cs
- EntityTypeBase.cs
- PageContentAsyncResult.cs
- DelegatedStream.cs
- odbcmetadatacolumnnames.cs
- EntityContainerAssociationSet.cs
- SqlDataAdapter.cs
- DbParameterHelper.cs
- DoubleLink.cs
- GZipDecoder.cs
- RegistrySecurity.cs
- ByteStream.cs
- FixedLineResult.cs
- WeakReferenceEnumerator.cs
- RadioButton.cs
- InkCanvasAutomationPeer.cs
- BufferedReadStream.cs
- WmpBitmapEncoder.cs
- HandleRef.cs
- WebPartsPersonalization.cs
- SchemaImporter.cs
- OleDbReferenceCollection.cs
- SimpleHandlerFactory.cs
- FixedPosition.cs
- ProfileModule.cs
- HttpCachePolicyElement.cs
- CryptoProvider.cs
- WorkflowMarkupSerializationException.cs
- UidPropertyAttribute.cs
- _emptywebproxy.cs
- SimpleTextLine.cs
- FrameworkElement.cs
- ScrollProperties.cs
- SHA384Managed.cs
- XmlNamespaceMapping.cs
- StringReader.cs
- ProtocolViolationException.cs
- SqlInternalConnectionTds.cs
- iisPickupDirectory.cs
- MasterPageBuildProvider.cs
- SqlConnection.cs
- RegisteredExpandoAttribute.cs