Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.ServiceModel.Web / System / ServiceModel / Dispatcher / MultiplexingDispatchMessageFormatter.cs / 1305376 / MultiplexingDispatchMessageFormatter.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Dispatcher { using System; using System.Collections.Generic; using System.Net.Mime; using System.Runtime; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.ServiceModel.Web; class MultiplexingDispatchMessageFormatter : IDispatchMessageFormatter { Dictionaryformatters; WebMessageFormat defaultFormat; Dictionary defaultContentTypes; public WebMessageFormat DefaultFormat { get { return this.defaultFormat; } } public Dictionary DefaultContentTypes { get { return this.defaultContentTypes; } } public MultiplexingDispatchMessageFormatter(Dictionary formatters, WebMessageFormat defaultFormat) { if (formatters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("formatters"); } this.formatters = formatters; this.defaultFormat = defaultFormat; this.defaultContentTypes = new Dictionary (); Fx.Assert(this.formatters.ContainsKey(this.defaultFormat), "The default format should always be included in the dictionary of formatters."); } public void DeserializeRequest(Message message, object[] parameters) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.GetString(SR2.SerializingRequestNotSupportedByFormatter, this))); } public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result) { OutgoingWebResponseContext outgoingResponse = WebOperationContext.Current.OutgoingResponse; WebMessageFormat? nullableFormat = outgoingResponse.Format; WebMessageFormat format = nullableFormat ?? this.defaultFormat; if (!this.formatters.ContainsKey(format)) { string operationName = " "; MessageProperties messageProperties = OperationContext.Current.IncomingMessageProperties; if (messageProperties.ContainsKey(WebHttpDispatchOperationSelector.HttpOperationNamePropertyName)) { operationName = messageProperties[WebHttpDispatchOperationSelector.HttpOperationNamePropertyName] as string; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.GetString(SR2.OperationDoesNotSupportFormat, operationName, format.ToString()))); } if (string.IsNullOrEmpty(outgoingResponse.ContentType)) { string automatedSelectionContentType = outgoingResponse.AutomatedFormatSelectionContentType; if (!string.IsNullOrEmpty(automatedSelectionContentType)) { // Don't set the content-type if it is default xml for backwards compatiabilty if (!string.Equals(automatedSelectionContentType, defaultContentTypes[WebMessageFormat.Xml], StringComparison.OrdinalIgnoreCase)) { outgoingResponse.ContentType = automatedSelectionContentType; } } else { // Don't set the content-type if it is default xml for backwards compatiabilty if (format != WebMessageFormat.Xml) { outgoingResponse.ContentType = defaultContentTypes[format]; } } } Message message = this.formatters[format].SerializeReply(messageVersion, parameters, result); return message; } public bool SupportsMessageFormat(WebMessageFormat format) { return this.formatters.ContainsKey(format); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ApplicationServiceManager.cs
- WorkflowMarkupSerializer.cs
- EntityTypeBase.cs
- GlobalProxySelection.cs
- SpotLight.cs
- mactripleDES.cs
- StringDictionaryEditor.cs
- SqlAliasesReferenced.cs
- CommonProperties.cs
- UInt16.cs
- PeerCollaborationPermission.cs
- UpDownEvent.cs
- XmlKeywords.cs
- CursorConverter.cs
- XslTransform.cs
- LinearKeyFrames.cs
- XmlDictionaryString.cs
- TdsParserHelperClasses.cs
- SqlCachedBuffer.cs
- dataprotectionpermission.cs
- ListControlBoundActionList.cs
- CommonRemoteMemoryBlock.cs
- PropertyPushdownHelper.cs
- ToolStripItemImageRenderEventArgs.cs
- DiscoveryInnerClientAdhoc11.cs
- SqlDataSourceQueryConverter.cs
- TextOnlyOutput.cs
- OutOfProcStateClientManager.cs
- BeginStoryboard.cs
- ApplicationServiceManager.cs
- FileRecordSequenceHelper.cs
- HttpListenerContext.cs
- WebPartConnectionsConnectVerb.cs
- UnaryNode.cs
- StyleConverter.cs
- GridViewUpdatedEventArgs.cs
- Configuration.cs
- Vector3DCollection.cs
- TransactionFlowOption.cs
- FixedSOMLineRanges.cs
- PagesSection.cs
- GridLength.cs
- BrowserCapabilitiesCompiler.cs
- Object.cs
- Fonts.cs
- CookielessData.cs
- XmlCharType.cs
- Serializer.cs
- Pair.cs
- Quad.cs
- AuthStoreRoleProvider.cs
- XPathParser.cs
- ClientOptions.cs
- DocumentPageViewAutomationPeer.cs
- PanelStyle.cs
- SQLInt32.cs
- RegexStringValidator.cs
- WebPartDescriptionCollection.cs
- NewArrayExpression.cs
- ApplicationTrust.cs
- LookupNode.cs
- XsdBuilder.cs
- FormatterServices.cs
- BufferAllocator.cs
- StylusButtonEventArgs.cs
- VectorCollectionValueSerializer.cs
- SchemaInfo.cs
- BinaryKeyIdentifierClause.cs
- TabOrder.cs
- FormsAuthenticationModule.cs
- AnonymousIdentificationSection.cs
- FirewallWrapper.cs
- RadioButton.cs
- XmlIlTypeHelper.cs
- OrderByQueryOptionExpression.cs
- XmlBinaryReader.cs
- DLinqAssociationProvider.cs
- CodeTypeReferenceExpression.cs
- EventLogPropertySelector.cs
- PanelDesigner.cs
- ErasingStroke.cs
- StagingAreaInputItem.cs
- DBParameter.cs
- DataGridBoolColumn.cs
- CqlErrorHelper.cs
- HtmlElementEventArgs.cs
- SerTrace.cs
- HttpStreamMessageEncoderFactory.cs
- UnsafeNativeMethods.cs
- ProcessProtocolHandler.cs
- OneOfElement.cs
- Events.cs
- EpmSyndicationContentSerializer.cs
- DataGridSortCommandEventArgs.cs
- ProcessThreadCollection.cs
- StateItem.cs
- XmlQueryType.cs
- HGlobalSafeHandle.cs
- TypeInitializationException.cs
- ContentTypeSettingClientMessageFormatter.cs