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
- NestedContainer.cs
- ModelVisual3D.cs
- GlobalizationAssembly.cs
- FigureParagraph.cs
- FirstMatchCodeGroup.cs
- Pair.cs
- XPathNavigatorKeyComparer.cs
- NumberFormatter.cs
- ArrangedElement.cs
- RegexTree.cs
- SectionXmlInfo.cs
- Triplet.cs
- TreeNode.cs
- TypeForwardedFromAttribute.cs
- AsymmetricAlgorithm.cs
- UncommonField.cs
- TypefaceMetricsCache.cs
- SslStream.cs
- GenericQueueSurrogate.cs
- InfiniteIntConverter.cs
- TypeElementCollection.cs
- HMACSHA256.cs
- ProcessHostMapPath.cs
- ClientType.cs
- ErrorsHelper.cs
- TaskExtensions.cs
- QilValidationVisitor.cs
- CodeThrowExceptionStatement.cs
- PeerToPeerException.cs
- BuildResult.cs
- RequestDescription.cs
- DefaultValueConverter.cs
- WebPartDisplayModeCollection.cs
- ControlBuilderAttribute.cs
- DependencyObject.cs
- XslAst.cs
- _ListenerResponseStream.cs
- ImageBrush.cs
- EntityDataSourceDataSelection.cs
- BaseHashHelper.cs
- SafeNativeMethods.cs
- FeatureAttribute.cs
- ComPlusThreadInitializer.cs
- PictureBox.cs
- DBSchemaRow.cs
- DbProviderServices.cs
- DefaultValueTypeConverter.cs
- Emitter.cs
- Matrix.cs
- OleDbDataReader.cs
- WebFormDesignerActionService.cs
- ContextMenuStripGroup.cs
- DataIdProcessor.cs
- AppDomainCompilerProxy.cs
- AutomationPropertyInfo.cs
- XmlAutoDetectWriter.cs
- WorkflowIdleBehavior.cs
- StateItem.cs
- TypeConvertions.cs
- DataGridViewCellConverter.cs
- MediaElementAutomationPeer.cs
- PopupControlService.cs
- HandledMouseEvent.cs
- EntitySqlQueryState.cs
- DataSourceExpressionCollection.cs
- Exceptions.cs
- XmlSchemaSimpleContentRestriction.cs
- AppModelKnownContentFactory.cs
- HealthMonitoringSectionHelper.cs
- SqlReferenceCollection.cs
- FrameworkReadOnlyPropertyMetadata.cs
- PolyBezierSegmentFigureLogic.cs
- AttributeExtensions.cs
- XmlDataDocument.cs
- AdornedElementPlaceholder.cs
- RelatedPropertyManager.cs
- FileDataSourceCache.cs
- DrawingContextDrawingContextWalker.cs
- ApplicationSecurityManager.cs
- HttpCookie.cs
- PowerStatus.cs
- WebPartZoneCollection.cs
- IPEndPointCollection.cs
- Freezable.cs
- MsmqException.cs
- ControlType.cs
- ListViewItemMouseHoverEvent.cs
- FindCriteria11.cs
- NameValueSectionHandler.cs
- BamlLocalizableResourceKey.cs
- ResumeStoryboard.cs
- SQLGuid.cs
- DirectoryObjectSecurity.cs
- XmlLoader.cs
- HtmlInputImage.cs
- SynchronizationContext.cs
- XmlTextWriter.cs
- FormsAuthenticationUser.cs
- PropertyMetadata.cs
- HMAC.cs