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
- CustomTypeDescriptor.cs
- ElementHostAutomationPeer.cs
- InvokePatternIdentifiers.cs
- Vector3D.cs
- NetworkInformationPermission.cs
- ExitEventArgs.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- HtmlInputRadioButton.cs
- XmlArrayItemAttribute.cs
- DefaultAsyncDataDispatcher.cs
- Zone.cs
- CodeGroup.cs
- DocumentApplication.cs
- ActivityDesignerAccessibleObject.cs
- MasterPageBuildProvider.cs
- AnnotationMap.cs
- HtmlGenericControl.cs
- OneOfScalarConst.cs
- ISAPIWorkerRequest.cs
- Italic.cs
- FixedPosition.cs
- odbcmetadatafactory.cs
- ICspAsymmetricAlgorithm.cs
- sapiproxy.cs
- DrawingState.cs
- TransactionWaitAsyncResult.cs
- EntityContainer.cs
- InfiniteTimeSpanConverter.cs
- OpacityConverter.cs
- VScrollBar.cs
- ToolStripArrowRenderEventArgs.cs
- PolicyLevel.cs
- EventItfInfo.cs
- IdentityManager.cs
- SoapFault.cs
- SBCSCodePageEncoding.cs
- Base64Encoder.cs
- BrushValueSerializer.cs
- PerformanceCounter.cs
- WrappedIUnknown.cs
- MeshGeometry3D.cs
- TemplateColumn.cs
- GridViewRowEventArgs.cs
- XmlEntity.cs
- Roles.cs
- ManipulationLogic.cs
- ExpandableObjectConverter.cs
- FormViewDeleteEventArgs.cs
- Button.cs
- ReadOnlyDictionary.cs
- RowTypeElement.cs
- IisTraceWebEventProvider.cs
- Avt.cs
- CultureSpecificCharacterBufferRange.cs
- WebPartMinimizeVerb.cs
- MetabaseServerConfig.cs
- CreateUserWizardStep.cs
- WindowsFormsLinkLabel.cs
- XmlNamedNodeMap.cs
- RoutedPropertyChangedEventArgs.cs
- EnumMember.cs
- StandardBindingReliableSessionElement.cs
- ScriptingSectionGroup.cs
- indexingfiltermarshaler.cs
- Scheduler.cs
- UserControlBuildProvider.cs
- KnownBoxes.cs
- InitiatorSessionSymmetricMessageSecurityProtocol.cs
- XmlSchemaObject.cs
- RegexGroup.cs
- BitmapMetadata.cs
- SQLByte.cs
- ButtonColumn.cs
- CharacterBufferReference.cs
- ModulesEntry.cs
- BaseValidator.cs
- MetadataHelper.cs
- RegexInterpreter.cs
- ServiceModelActivationSectionGroup.cs
- PassportAuthenticationEventArgs.cs
- Mappings.cs
- UriWriter.cs
- ArglessEventHandlerProxy.cs
- TableDetailsRow.cs
- XamlFxTrace.cs
- HttpCachePolicyWrapper.cs
- UnsafeNativeMethods.cs
- CodeThrowExceptionStatement.cs
- IPEndPointCollection.cs
- ListSortDescription.cs
- DesignerTextWriter.cs
- ReturnType.cs
- PropertyMetadata.cs
- DeferredSelectedIndexReference.cs
- PageParserFilter.cs
- mansign.cs
- XmlSchemaAttribute.cs
- AdapterDictionary.cs
- StaticTextPointer.cs
- SelectionUIService.cs