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
- AutoGeneratedField.cs
- ConstraintConverter.cs
- SiteMapDataSourceView.cs
- NavigationFailedEventArgs.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- DirectionalLight.cs
- FamilyMapCollection.cs
- DataServiceExpressionVisitor.cs
- RowUpdatedEventArgs.cs
- Size3D.cs
- AQNBuilder.cs
- NavigateEvent.cs
- ModelProperty.cs
- IDQuery.cs
- TransactedReceiveData.cs
- FrameworkEventSource.cs
- UidPropertyAttribute.cs
- EntityDataSourceStatementEditor.cs
- DeclarationUpdate.cs
- WebSysDefaultValueAttribute.cs
- util.cs
- BamlVersionHeader.cs
- DeviceContext.cs
- DataGridViewTextBoxEditingControl.cs
- DebuggerAttributes.cs
- SHA1CryptoServiceProvider.cs
- ToolStripDropDown.cs
- GridViewSelectEventArgs.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ColumnCollection.cs
- InternalRelationshipCollection.cs
- DBCommandBuilder.cs
- RemoveFromCollection.cs
- DataSvcMapFileSerializer.cs
- PageAsyncTask.cs
- RemotingConfiguration.cs
- ValueExpressions.cs
- ResourcePart.cs
- ItemsChangedEventArgs.cs
- TemplatedEditableDesignerRegion.cs
- XmlQueryType.cs
- ExceptionHandlers.cs
- HighContrastHelper.cs
- PreservationFileWriter.cs
- ErrorWebPart.cs
- FormatterConverter.cs
- SocketException.cs
- ComplexBindingPropertiesAttribute.cs
- CellCreator.cs
- TreeNodeConverter.cs
- AsyncDataRequest.cs
- ResourceSetExpression.cs
- HtmlHistory.cs
- ExtentJoinTreeNode.cs
- WebBrowserDocumentCompletedEventHandler.cs
- ContentPresenter.cs
- BamlRecordWriter.cs
- BinaryMessageFormatter.cs
- Rule.cs
- MediaEntryAttribute.cs
- ToolStripPanelCell.cs
- EventPrivateKey.cs
- ClassData.cs
- Style.cs
- Profiler.cs
- CodeDOMUtility.cs
- Cloud.cs
- PackageRelationshipCollection.cs
- HtmlEmptyTagControlBuilder.cs
- DataGridViewSelectedCellCollection.cs
- Light.cs
- QueryConverter.cs
- DrawingAttributesDefaultValueFactory.cs
- Point3DValueSerializer.cs
- StretchValidation.cs
- CachedCompositeFamily.cs
- PaginationProgressEventArgs.cs
- EnumerableValidator.cs
- OleDbParameter.cs
- RadioButton.cs
- XmlEntity.cs
- CachingHintValidation.cs
- DocumentPageView.cs
- BuilderElements.cs
- ECDiffieHellmanCng.cs
- ManifestResourceInfo.cs
- RelationshipDetailsRow.cs
- SqlServices.cs
- Switch.cs
- DynamicControl.cs
- AssemblyAttributes.cs
- SatelliteContractVersionAttribute.cs
- ToolStripItemImageRenderEventArgs.cs
- ClientType.cs
- SqlBooleanizer.cs
- Vector3dCollection.cs
- ServiceEndpointAssociationProvider.cs
- ContractMethodParameterInfo.cs
- VScrollProperties.cs
- Win32MouseDevice.cs