23 |
*/ |
*/ |
24 |
using System.Runtime.Serialization; |
using System.Runtime.Serialization; |
25 |
using System.IO; |
using System.IO; |
26 |
|
using DotGNU.XmlRpc; |
27 |
|
using System.Xml; |
28 |
|
|
29 |
namespace DotGNU.XmlRpc.Serialization |
namespace DotGNU.XmlRpc.Serialization.Formatters |
30 |
{ |
{ |
31 |
public sealed class MethodCallFormatter : IFormatter |
public sealed class MethodCallFormatter : IFormatter |
32 |
{ |
{ |
33 |
|
private SerializationBinder binder; |
34 |
|
private StreamingContext context; |
35 |
|
private ISurrogateSelector surrogateSelector; |
36 |
|
|
37 |
|
public MethodCallFormatter() |
38 |
|
{ |
39 |
|
context = new StreamingContext( StreamingContextStates.All ); |
40 |
|
} |
41 |
|
|
42 |
|
// Returns a XmlRpcMethod object from the incoming stream |
43 |
public object Deserialize( Stream stream ) |
public object Deserialize( Stream stream ) |
44 |
{ |
{ |
45 |
return null; |
StreamReader reader = new StreamReader( stream ); |
46 |
|
XmlTextReader tr = new XmlTextReader( stream ); |
47 |
|
XmlRpcMethod method = new XmlRpcMethod(); |
48 |
|
method.Read( tr ); |
49 |
|
|
50 |
|
return method; |
51 |
} |
} |
52 |
|
|
53 |
|
// Writes a XmlRpc MethodCall from the XmlRpcMethod object |
54 |
public void Serialize( Stream stream, object o ) |
public void Serialize( Stream stream, object o ) |
55 |
{ |
{ |
56 |
|
if( o is XmlRpcMethod ) { |
57 |
|
StreamWriter sw = new StreamWriter( stream ); |
58 |
|
StringWriter s = new StringWriter(); |
59 |
|
XmlRpcWriter w = new XmlRpcWriter( s ); |
60 |
|
w.Write( (XmlRpcMethod)o ); |
61 |
|
sw.Write( s.ToString() ); |
62 |
|
sw.Flush(); |
63 |
|
} |
64 |
|
else { |
65 |
|
Console.Out.WriteLine |
66 |
|
( "BUMMER: wrong type given: {0}, expected and object of type {1}", |
67 |
|
o.GetType(), "DotGNU.XmlRpc.XmlRpcMethod" ); |
68 |
|
} |
69 |
} |
} |
70 |
|
|
71 |
public SerializationBinder Binder |
public SerializationBinder Binder |
72 |
{ |
{ |
73 |
get{ |
get{ |
74 |
return null; |
return this.binder; |
75 |
} |
} |
76 |
set{ |
set{ |
77 |
|
this.binder = value; |
78 |
} |
} |
79 |
} |
} |
80 |
|
|
90 |
public ISurrogateSelector SurrogateSelector |
public ISurrogateSelector SurrogateSelector |
91 |
{ |
{ |
92 |
get { |
get { |
93 |
return null; |
return this.surrogateSelector; |
|
|
|
94 |
} |
} |
95 |
set { |
set { |
96 |
|
this.surrogateSelector = value; |
97 |
} |
} |
98 |
} |
} |
99 |
} |
} |