/[dgee]/dgee/cslib/DotGNU/XmlRpc/Serialization/MethodResponseFormatter.cs
ViewVC logotype

Diff of /dgee/cslib/DotGNU/XmlRpc/Serialization/MethodResponseFormatter.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by npg, Sun Jul 27 12:47:53 2003 UTC revision 1.2 by csmith, Sun Sep 21 10:55:47 2003 UTC
# Line 0  Line 1 
1    /*
2     * DotGNU XmlRpc implementation
3     *
4     * Copyright (C) 2003  Free Software Foundation, Inc.
5     *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19     *
20     * $Revision$  $Date$
21     *
22     * --------------------------------------------------------------------------
23     */
24    using System.Runtime.Serialization;
25    using System.IO;
26    using System.Xml;
27    using DotGNU.XmlRpc;
28    
29    namespace DotGNU.XmlRpc.Serialization.Formatters
30    {
31      public sealed class MethodResponseFormatter : IFormatter
32      {
33        private SerializationBinder binder;
34        private StreamingContext context;
35        private ISurrogateSelector surrogateSelector;
36    
37        public MethodResponseFormatter()
38        {
39          context = new StreamingContext( StreamingContextStates.All );
40        }
41    
42        // Returns the object wrapped in the XmlRpc response
43        public object Deserialize( Stream stream )
44        {
45          StreamReader reader = new StreamReader( stream );
46          XmlTextReader tr = new XmlTextReader( stream );
47          XmlRpcResponse response = new XmlRpcResponse();
48          response.Read( tr );
49    
50          return response;
51        }
52    
53        // Writes an object as an XmlRpc response
54        public void Serialize( Stream stream, object o )
55        {
56          if( o is XmlRpcResponse ){
57            StreamWriter sw = new StreamWriter( stream );
58            StringWriter s = new StringWriter();
59            XmlRpcWriter w = new XmlRpcWriter( sw );
60            w.Write( (XmlRpcResponse)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.XmlRpcResponse" );
68          }
69        }
70    
71        public SerializationBinder Binder
72        {
73          get{
74            return this.binder;
75          }
76          set{
77            this.binder = value;
78          }
79        }
80    
81        public StreamingContext Context
82        {
83          get{
84            return new StreamingContext();
85          }
86          set {
87          }
88        }
89        
90        public ISurrogateSelector SurrogateSelector
91        {
92          get {
93            return this.surrogateSelector;
94          }
95          set {
96            this.surrogateSelector = value;
97          }
98        }
99      }
100    }
101    
102    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26