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
- UidManager.cs
- LocationSectionRecord.cs
- FormViewDesigner.cs
- UnsafeNativeMethods.cs
- LinqDataSourceContextEventArgs.cs
- SamlAuthenticationStatement.cs
- Stackframe.cs
- BindUriHelper.cs
- GroupBoxRenderer.cs
- ErrorFormatter.cs
- ZipIOExtraFieldPaddingElement.cs
- DbMetaDataCollectionNames.cs
- DBParameter.cs
- DbConnectionClosed.cs
- BrowserCapabilitiesFactory.cs
- StickyNoteContentControl.cs
- ExtenderProvidedPropertyAttribute.cs
- FrameworkContextData.cs
- DefaultBindingPropertyAttribute.cs
- Thumb.cs
- DialogResultConverter.cs
- DispatcherObject.cs
- CodeLinePragma.cs
- ConnectorSelectionGlyph.cs
- SystemIcons.cs
- ImageUrlEditor.cs
- BufferModesCollection.cs
- ObjectFullSpanRewriter.cs
- BroadcastEventHelper.cs
- UserPreferenceChangedEventArgs.cs
- Group.cs
- ScrollChrome.cs
- SignedInfo.cs
- XMLSchema.cs
- BitmapEffectState.cs
- VectorAnimationBase.cs
- FlowLayout.cs
- ModelToObjectValueConverter.cs
- UnicodeEncoding.cs
- ICollection.cs
- DesignerForm.cs
- Configuration.cs
- PageContentCollection.cs
- MultipleViewPatternIdentifiers.cs
- _HeaderInfoTable.cs
- XamlToRtfParser.cs
- GifBitmapDecoder.cs
- DataGridColumnStyleMappingNameEditor.cs
- ResolveMatches11.cs
- WinFormsSecurity.cs
- HScrollBar.cs
- EdmPropertyAttribute.cs
- TextLine.cs
- TraceHandler.cs
- HopperCache.cs
- InitializerFacet.cs
- UiaCoreTypesApi.cs
- TemplateKeyConverter.cs
- PropertyChangedEventManager.cs
- RTTypeWrapper.cs
- TextPointerBase.cs
- EventHandlerService.cs
- WebPartCancelEventArgs.cs
- AnchoredBlock.cs
- Label.cs
- PageEventArgs.cs
- SqlDataSourceCommandEventArgs.cs
- MenuAdapter.cs
- xsdvalidator.cs
- FieldAccessException.cs
- ResetableIterator.cs
- DocumentViewerConstants.cs
- Registry.cs
- LineServicesCallbacks.cs
- EntityDesignerBuildProvider.cs
- XmlSchemaElement.cs
- ListControlStringCollectionEditor.cs
- CodeTypeOfExpression.cs
- CustomAttributeFormatException.cs
- SafeUserTokenHandle.cs
- COMException.cs
- GeometryGroup.cs
- TrayIconDesigner.cs
- LocalBuilder.cs
- ImageFormatConverter.cs
- Size.cs
- DataGridBoolColumn.cs
- LinqDataSourceDisposeEventArgs.cs
- ActivityCollectionMarkupSerializer.cs
- BitmapEffectvisualstate.cs
- webeventbuffer.cs
- SpeechDetectedEventArgs.cs
- TransformerConfigurationWizardBase.cs
- FontSourceCollection.cs
- WindowsAltTab.cs
- NativeMethods.cs
- HMACSHA384.cs
- MultiSelectRootGridEntry.cs
- VSWCFServiceContractGenerator.cs
- HtmlInputControl.cs