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
- KoreanLunisolarCalendar.cs
- DrawToolTipEventArgs.cs
- _ServiceNameStore.cs
- _SslSessionsCache.cs
- BindingNavigator.cs
- PermissionSetTriple.cs
- XamlWriterExtensions.cs
- ColorMatrix.cs
- NullableLongAverageAggregationOperator.cs
- TraceLog.cs
- WindowsTooltip.cs
- URLBuilder.cs
- DynamicResourceExtensionConverter.cs
- EDesignUtil.cs
- CodeDirectionExpression.cs
- OleDbDataReader.cs
- XsltCompileContext.cs
- InitializationEventAttribute.cs
- OleDbTransaction.cs
- ListDictionary.cs
- FilterUserControlBase.cs
- COSERVERINFO.cs
- WorkflowViewStateService.cs
- UnsafeNativeMethods.cs
- EventLogWatcher.cs
- ConfigurationSectionCollection.cs
- namescope.cs
- XmlAttributes.cs
- TypeSystem.cs
- DocumentDesigner.cs
- PointF.cs
- MouseGesture.cs
- XPathNodeHelper.cs
- CollectionBuilder.cs
- ThreadSafeList.cs
- ChameleonKey.cs
- InteropAutomationProvider.cs
- TimeoutTimer.cs
- FlowLayoutPanel.cs
- SimpleHandlerBuildProvider.cs
- SynchronizedDispatch.cs
- InputManager.cs
- PriorityQueue.cs
- ClientConfigurationHost.cs
- SkewTransform.cs
- AuthenticationServiceManager.cs
- SoapExtensionStream.cs
- TimersDescriptionAttribute.cs
- ExpressionBuilderContext.cs
- ListBoxDesigner.cs
- Debug.cs
- RightsManagementEncryptionTransform.cs
- CodeSnippetStatement.cs
- ScriptReferenceEventArgs.cs
- String.cs
- Utilities.cs
- ByteFacetDescriptionElement.cs
- ChtmlTextWriter.cs
- DynamicArgumentDesigner.xaml.cs
- KeysConverter.cs
- AssemblyAttributesGoHere.cs
- NameValueCollection.cs
- HelpEvent.cs
- ListDictionaryInternal.cs
- HttpProtocolReflector.cs
- TextBox.cs
- SourceItem.cs
- XmlReflectionMember.cs
- XmlDictionaryWriter.cs
- ShapeTypeface.cs
- ProcessHostMapPath.cs
- UIElement.cs
- CharConverter.cs
- WebPartConnectionsCancelEventArgs.cs
- KeyGesture.cs
- ExpressionBindingCollection.cs
- SchemaAttDef.cs
- QueryableDataSource.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- GregorianCalendar.cs
- SmiTypedGetterSetter.cs
- TemplateInstanceAttribute.cs
- CodeTypeParameterCollection.cs
- SecurityUtils.cs
- KeyedQueue.cs
- ShortcutKeysEditor.cs
- XmlUtilWriter.cs
- Nodes.cs
- Helpers.cs
- RuntimeCompatibilityAttribute.cs
- EDesignUtil.cs
- IndexerNameAttribute.cs
- SqlTrackingQuery.cs
- SqlXmlStorage.cs
- SapiInterop.cs
- UnauthorizedWebPart.cs
- EncodingStreamWrapper.cs
- AnimationClockResource.cs
- SqlClientMetaDataCollectionNames.cs
- TablePattern.cs