| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | using System.Text; |
| | | 6 | | using CoreWCF.Channels; |
| | | 7 | | using CoreWCF.Web; |
| | | 8 | | |
| | | 9 | | namespace CoreWCF.Dispatcher |
| | | 10 | | { |
| | | 11 | | internal class XmlFormatMapping : MultiplexingFormatMapping |
| | | 12 | | { |
| | 1 | 13 | | public static readonly WebContentFormat WebContentFormat = WebContentFormat.Xml; |
| | | 14 | | |
| | 1 | 15 | | internal static readonly string s_defaultMediaType = "application/xml"; |
| | 1 | 16 | | private static readonly Dictionary<Encoding, MessageEncoder> s_encoders = new Dictionary<Encoding, MessageEncode |
| | 1 | 17 | | private static readonly object s_thisLock = new object(); |
| | | 18 | | |
| | | 19 | | public XmlFormatMapping(Encoding writeEncoding, WebContentTypeMapper contentTypeMapper) |
| | 37 | 20 | | : base(writeEncoding, contentTypeMapper) |
| | 37 | 21 | | { } |
| | | 22 | | |
| | 0 | 23 | | public override WebContentFormat ContentFormat => WebContentFormat; |
| | | 24 | | |
| | 0 | 25 | | public override WebMessageFormat MessageFormat => WebMessageFormat.Xml; |
| | | 26 | | |
| | 37 | 27 | | public override string DefaultMediaType => s_defaultMediaType; |
| | | 28 | | |
| | | 29 | | protected override MessageEncoder Encoder |
| | | 30 | | { |
| | | 31 | | get |
| | | 32 | | { |
| | 0 | 33 | | lock (s_thisLock) |
| | | 34 | | { |
| | 0 | 35 | | if (!s_encoders.ContainsKey(writeEncoding)) |
| | | 36 | | { |
| | 0 | 37 | | s_encoders[writeEncoding] = new TextMessageEncodingBindingElement(MessageVersion.None, writeEnco |
| | | 38 | | } |
| | 0 | 39 | | } |
| | | 40 | | |
| | 0 | 41 | | return s_encoders[writeEncoding]; |
| | | 42 | | } |
| | | 43 | | } |
| | | 44 | | } |
| | | 45 | | } |