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
- NativeMethods.cs
- OletxDependentTransaction.cs
- LiteralDesigner.cs
- Matrix3DValueSerializer.cs
- NamedPermissionSet.cs
- SqlTypeSystemProvider.cs
- Token.cs
- RemotingAttributes.cs
- PersonalizableAttribute.cs
- CellCreator.cs
- LoginUtil.cs
- IdnElement.cs
- InvalidDocumentContentsException.cs
- SafeCloseHandleCritical.cs
- CellPartitioner.cs
- AccessDataSourceView.cs
- SafeViewOfFileHandle.cs
- HttpProfileGroupBase.cs
- WebPartDescription.cs
- GeometryGroup.cs
- PropertyChangedEventArgs.cs
- LambdaCompiler.Generated.cs
- Int16Converter.cs
- BookmarkManager.cs
- ReaderOutput.cs
- ValueType.cs
- Propagator.JoinPropagator.cs
- XmlReaderDelegator.cs
- ListSortDescription.cs
- WebPartMenu.cs
- PresentationAppDomainManager.cs
- MemoryRecordBuffer.cs
- SamlDoNotCacheCondition.cs
- StringValidator.cs
- LightweightEntityWrapper.cs
- EntityContainer.cs
- Socket.cs
- DBCSCodePageEncoding.cs
- UniformGrid.cs
- QilLiteral.cs
- CallContext.cs
- DataGridViewColumnCollection.cs
- SpeechSynthesizer.cs
- EventLogPermissionAttribute.cs
- IsolatedStorageSecurityState.cs
- LoginView.cs
- ConfigUtil.cs
- EncodingInfo.cs
- PermissionAttributes.cs
- ToolStripGripRenderEventArgs.cs
- SQLCharsStorage.cs
- TypedElement.cs
- _BaseOverlappedAsyncResult.cs
- HtmlInputHidden.cs
- DependentTransaction.cs
- MetadataArtifactLoaderComposite.cs
- SectionVisual.cs
- CompensationExtension.cs
- StorageRoot.cs
- TrackingRecord.cs
- Rules.cs
- PointValueSerializer.cs
- AdapterDictionary.cs
- WebPartVerb.cs
- GeneralTransform2DTo3D.cs
- CompensatableTransactionScopeActivity.cs
- AutomationElement.cs
- Transform.cs
- DebugView.cs
- TypeSchema.cs
- SqlUtils.cs
- SubclassTypeValidatorAttribute.cs
- Metafile.cs
- DurableOperationContext.cs
- FamilyMap.cs
- StringUtil.cs
- LicenseProviderAttribute.cs
- TypeConvertions.cs
- DesignTimeParseData.cs
- LOSFormatter.cs
- Configuration.cs
- assertwrapper.cs
- XPathEmptyIterator.cs
- ObjectCloneHelper.cs
- dsa.cs
- WorkflowTerminatedException.cs
- XmlSecureResolver.cs
- IndexedGlyphRun.cs
- WindowsButton.cs
- CodeThrowExceptionStatement.cs
- ScrollEventArgs.cs
- FacetValueContainer.cs
- ToolBarDesigner.cs
- TypeConverterHelper.cs
- SafeRightsManagementSessionHandle.cs
- MimeBasePart.cs
- SqlServer2KCompatibilityAnnotation.cs
- ExpressionVisitor.cs
- TabControlEvent.cs
- xmlNames.cs