Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / NetFx35 / System.ServiceModel.Web / System / ServiceModel / Dispatcher / ContentTypeSettingDispatchMessageFormatter.cs / 1 / ContentTypeSettingDispatchMessageFormatter.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.Web; class ContentTypeSettingDispatchMessageFormatter : IDispatchMessageFormatter { IDispatchMessageFormatter innerFormatter; string outgoingContentType; public ContentTypeSettingDispatchMessageFormatter(string outgoingContentType, IDispatchMessageFormatter innerFormatter) { if (outgoingContentType == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("outgoingContentType"); } if (innerFormatter == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("innerFormatter"); } this.outgoingContentType = outgoingContentType; this.innerFormatter = innerFormatter; } public void DeserializeRequest(Message message, object[] parameters) { this.innerFormatter.DeserializeRequest(message, parameters); } public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result) { Message message = this.innerFormatter.SerializeReply(messageVersion, parameters, result); if (message != null) { AddResponseContentTypeProperty(message, this.outgoingContentType); } return message; } static void AddResponseContentTypeProperty(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.OutgoingResponse.ContentType)) { WebOperationContext.Current.OutgoingResponse.ContentType = contentType; } } else { object prop; message.Properties.TryGetValue(HttpResponseMessageProperty.Name, out prop); HttpResponseMessageProperty httpProperty; if (prop != null) { httpProperty = (HttpResponseMessageProperty) prop; } else { httpProperty = new HttpResponseMessageProperty(); message.Properties.Add(HttpResponseMessageProperty.Name, httpProperty); } if (string.IsNullOrEmpty(httpProperty.Headers[HttpResponseHeader.ContentType])) { httpProperty.Headers[HttpResponseHeader.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
- CharUnicodeInfo.cs
- Bitmap.cs
- StringComparer.cs
- WindowsAltTab.cs
- EntityExpressionVisitor.cs
- SmtpCommands.cs
- RowsCopiedEventArgs.cs
- SqlOuterApplyReducer.cs
- FlatButtonAppearance.cs
- AccessedThroughPropertyAttribute.cs
- DiagnosticEventProvider.cs
- WebColorConverter.cs
- Vector3DCollectionConverter.cs
- TabControlCancelEvent.cs
- SqlInfoMessageEvent.cs
- SimpleParser.cs
- SqlDataSourceQueryEditor.cs
- HttpException.cs
- SqlServer2KCompatibilityCheck.cs
- UserValidatedEventArgs.cs
- FamilyTypefaceCollection.cs
- ToolboxItemCollection.cs
- HttpInputStream.cs
- WindowsGraphics.cs
- TextClipboardData.cs
- CodeDomExtensionMethods.cs
- TextFormatterImp.cs
- SharedPersonalizationStateInfo.cs
- ConditionCollection.cs
- ToolStripTextBox.cs
- Util.cs
- FilteredReadOnlyMetadataCollection.cs
- RegionInfo.cs
- XamlRtfConverter.cs
- BindingGroup.cs
- OleDbDataAdapter.cs
- BindingExpressionBase.cs
- RijndaelManagedTransform.cs
- RequestCachingSection.cs
- Errors.cs
- BookmarkTable.cs
- LeaseManager.cs
- OleStrCAMarshaler.cs
- Style.cs
- DeferredElementTreeState.cs
- GraphicsContainer.cs
- InfoCardTrace.cs
- XmlNodeChangedEventManager.cs
- PermissionListSet.cs
- ThreadStateException.cs
- KnownIds.cs
- AttributeUsageAttribute.cs
- FacetValueContainer.cs
- ClientSession.cs
- UserControl.cs
- XhtmlMobileTextWriter.cs
- DesignerActionUI.cs
- FunctionQuery.cs
- TransmissionStrategy.cs
- IUnknownConstantAttribute.cs
- BinaryNode.cs
- HttpCapabilitiesBase.cs
- DataGridDetailsPresenterAutomationPeer.cs
- ConfigurationValidatorAttribute.cs
- XmlText.cs
- SqlException.cs
- ProfileInfo.cs
- BrowserCapabilitiesFactoryBase.cs
- WorkflowTraceTransfer.cs
- GridViewCancelEditEventArgs.cs
- PluralizationService.cs
- IFlowDocumentViewer.cs
- Container.cs
- DataGridLinkButton.cs
- WindowsTab.cs
- PreservationFileWriter.cs
- StdRegProviderWrapper.cs
- X509Logo.cs
- AttributeExtensions.cs
- FormClosedEvent.cs
- Exceptions.cs
- EnumValAlphaComparer.cs
- WMIGenerator.cs
- ByteBufferPool.cs
- HttpModule.cs
- BasicCellRelation.cs
- MeshGeometry3D.cs
- SingleTagSectionHandler.cs
- HtmlContainerControl.cs
- metadatamappinghashervisitor.cs
- TranslateTransform.cs
- DbMetaDataCollectionNames.cs
- userdatakeys.cs
- XmlIncludeAttribute.cs
- CurrencyWrapper.cs
- PermissionRequestEvidence.cs
- RoutedEvent.cs
- ComPlusServiceLoader.cs
- CellTreeNode.cs
- LazyInitializer.cs