2010-04-15 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.ServiceModel / System.ServiceModel.Channels / MtomMessageEncoder.cs
blobdd86e6c5da8a375b01295689fda8da97d404e96a
1 //
2 // MtomMessageEncoder.cs
3 //
4 // Author: Atsushi Enomoto (atsushi@ximian.com)
5 //
6 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
15 //
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
18 //
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 using System;
28 using System.IO;
29 using System.Collections.ObjectModel;
30 using System.ServiceModel;
31 using System.Text;
32 using System.Xml;
34 namespace System.ServiceModel.Channels
36 internal class MtomMessageEncoder : MessageEncoder
38 Encoding encoding;
39 MessageVersion version;
41 public MtomMessageEncoder (MtomMessageEncoderFactory owner)
43 version = owner.MessageVersion;
44 encoding = owner.Owner.WriteEncoding;
47 public override string ContentType {
48 get { return "multipart/related; type=application/xop+xml"; }
51 public override string MediaType {
52 get { return "multipart/related"; }
55 public override MessageVersion MessageVersion {
56 get { return version; }
59 [MonoTODO]
60 public override Message ReadMessage (ArraySegment<byte> buffer,
61 BufferManager bufferManager, string contentType)
63 // FIXME: where should bufferManager be used?
64 // FIXME: no way to take maxSizeOfHeaders
65 // FIXME: create proper quotas
66 return Message.CreateMessage (
67 XmlDictionaryReader.CreateMtomReader (buffer.Array, buffer.Offset, buffer.Count, encoding, new XmlDictionaryReaderQuotas ()),
68 int.MaxValue,
69 MessageVersion);
72 [MonoTODO]
73 public override Message ReadMessage (Stream stream,
74 int maxSizeOfHeaders, string contentType)
76 // FIXME: create proper quotas
77 return Message.CreateMessage (
78 XmlDictionaryReader.CreateMtomReader (
79 stream, encoding, new XmlDictionaryReaderQuotas ()),
80 maxSizeOfHeaders,
81 MessageVersion);
84 [MonoTODO]
85 public override void WriteMessage (Message message, Stream stream)
87 VerifyMessageVersion (message);
89 // FIXME: no way to acquire maxSizeInBytes and startInfo?
90 message.WriteMessage (XmlDictionaryWriter.CreateMtomWriter (stream, encoding, int.MaxValue, null));
93 [MonoTODO]
94 public override ArraySegment<byte> WriteMessage (
95 Message message, int maxMessageSize,
96 BufferManager bufferManager, int messageOffset)
98 VerifyMessageVersion (message);
100 throw new NotImplementedException ();