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
- XsltContext.cs
- DataGrid.cs
- DefaultAsyncDataDispatcher.cs
- SelectionWordBreaker.cs
- XmlSchemaRedefine.cs
- AssertSection.cs
- CssTextWriter.cs
- PrintPageEvent.cs
- PassportAuthentication.cs
- InputReferenceExpression.cs
- StateItem.cs
- LogStore.cs
- RequestNavigateEventArgs.cs
- Setter.cs
- PersonalizablePropertyEntry.cs
- EditorPart.cs
- DbDataReader.cs
- ThemeDirectoryCompiler.cs
- SmiMetaData.cs
- OrderPreservingMergeHelper.cs
- CodeExporter.cs
- FontFamilyIdentifier.cs
- SerializationEventsCache.cs
- SymmetricSecurityBindingElement.cs
- OutOfMemoryException.cs
- RefExpr.cs
- EventHandlerList.cs
- CroppedBitmap.cs
- OleDbInfoMessageEvent.cs
- SqlDataSourceCache.cs
- ServiceProviders.cs
- ValidatorCompatibilityHelper.cs
- adornercollection.cs
- DesignTimeHTMLTextWriter.cs
- ThicknessConverter.cs
- itemelement.cs
- XmlExceptionHelper.cs
- CodeConstructor.cs
- CodeTypeMember.cs
- XXXOnTypeBuilderInstantiation.cs
- CatalogPartCollection.cs
- AuthenticatedStream.cs
- DesignerOptionService.cs
- InstalledFontCollection.cs
- ValuePattern.cs
- StorageEntityContainerMapping.cs
- AuthenticationConfig.cs
- BufferedGraphics.cs
- ListBox.cs
- TokenBasedSetEnumerator.cs
- WebBrowserEvent.cs
- serverconfig.cs
- LocalizabilityAttribute.cs
- ArrangedElement.cs
- VersionPair.cs
- PageHandlerFactory.cs
- ClipboardData.cs
- DefaultShape.cs
- HotCommands.cs
- MethodBody.cs
- SystemFonts.cs
- ListBoxItemAutomationPeer.cs
- DataGridViewTopLeftHeaderCell.cs
- ProcessThreadCollection.cs
- MaskedTextBoxTextEditor.cs
- Menu.cs
- RowToFieldTransformer.cs
- CompilationLock.cs
- Msec.cs
- TagPrefixInfo.cs
- StringValueConverter.cs
- SafeHandle.cs
- StyleHelper.cs
- BinaryObjectReader.cs
- ReadingWritingEntityEventArgs.cs
- ScriptHandlerFactory.cs
- CreateRefExpr.cs
- HotSpot.cs
- Accessible.cs
- AnnotationMap.cs
- ClientCultureInfo.cs
- ProofTokenCryptoHandle.cs
- BitmapMetadata.cs
- ExternalDataExchangeClient.cs
- PersistenceProviderBehavior.cs
- MsmqIntegrationElement.cs
- EdmProperty.cs
- GPPOINTF.cs
- FunctionQuery.cs
- Errors.cs
- DbException.cs
- PropertyDescriptorCollection.cs
- PageCodeDomTreeGenerator.cs
- WCFBuildProvider.cs
- ResourceDescriptionAttribute.cs
- ConfigXmlReader.cs
- TextReturnReader.cs
- XPathPatternParser.cs
- TableItemProviderWrapper.cs
- EdmToObjectNamespaceMap.cs