/[dgee]/dgee/cslib/DotGNU/XmlRpc/XmlRpcStruct.cs
ViewVC logotype

Diff of /dgee/cslib/DotGNU/XmlRpc/XmlRpcStruct.cs

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

revision 1.1.2.1.2.1 by npg, Mon Jul 21 14:49:11 2003 UTC revision 1.1.2.1.2.2 by npg, Mon Jul 21 16:23:20 2003 UTC
# Line 1  Line 1 
1  /*  /*
2     This library is free software; you can redistribute it and/or   * DotGNU XmlRpc implementation
3     modify it under the terms of the GNU Library General Public   *
4     License as published by the Free Software Foundation; either   * Copyright (C) 2002 netFluid Technology Ltd
5     version 2 of the License, or (at your option) any later version.   *
6       * This program is free software; you can redistribute it and/or modify
7     This library is distributed in the hope that it will be useful,   * it under the terms of the GNU General Public License as published by
8     but WITHOUT ANY WARRANTY; without even the implied warranty of   * the Free Software Foundation; either version 2 of the License, or
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   * (at your option) any later version.
10     Library General Public License for more details.   *
11     * This program is distributed in the hope that it will be useful,
12     You should have received a copy of the GNU Library General Public   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     License along with this library; if not, write to the Free   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,   * GNU General Public License for more details.
15     MA 02111-1307, USA   *
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  namespace DotGNU.XmlRpc   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19  {   *
20    using System;   * $Revision$  $Date$
21    using System.Collections;   *
22    using System.Runtime.Remoting;   * --------------------------------------------------------------------------
23       */
24    public class XmlRpcStruct : Hashtable  namespace DotGNU.XmlRpc
25    {  {
26      // TODO: add constructor with params args    using System.Collections;
27      public override void Add(object key, object value)  
28      {    public sealed class XmlRpcStruct : Hashtable
29        if (!(key is string))    {
30        {      private string key;
31          throw new Exception();      private object val;
32        }  
33        // returns the XML representation of this structure TODO:
34        if(XmlRpcDeserializer.GetXmlRpcType(value.GetType()) == XmlRpcParamType.tInvalid)      // formatting options for indented format.  This may have to be
35        {      // moved into the XmlRpcWriter...  we'll see
36          throw new Exception();      public override string ToString()
37        }      {
38          string members;
39        base.Add(key, value);        foreach( DictionaryEntry entry in this) {
40      }          members += String.Format(
41    "  <member>
42      public override bool Equals(Object obj)      <name>{0}</name>
43      {      <value>{1}</value>
44        if (obj.GetType() != typeof(XmlRpcStruct)) return false;    </member>
45    ", entry.Key, entry.Value );
46        XmlRpcStruct xmlRpcStruct = (XmlRpcStruct)obj;        }
47        if (this.Keys.Count != xmlRpcStruct.Count) return false;        
48          string s = String.Format(
49        foreach (String key in this.Keys)  "<struct>
50        {  {0}</struct>", members);
51          if (!xmlRpcStruct.ContainsKey(key)) return false;        return s;
52          if (!this[key].Equals(xmlRpcStruct[key])) return false;      }
53        }  
54        return true;      // set property for the Member Name
55      }      public string MemberName
56    }      {
57  }        set {
58            this.key = value;
59          }
60        }
61        
62        // set property for the Member Value
63        public object MemberValue
64        {
65          set {
66            this.val = value;
67          }
68        }
69        
70        // adds the key/value pair to the Structure and resets it to null
71        // so that we can test and ensure that neither member is being set
72        // twice (protocol error).  are we trusting users?  NOPE. :P
73        public void Commit()
74        {
75          // TODO: ensure both are not null before a commit
76          #if __DEBUG__
77          Console.Out.WriteLine( "Struct commit: key='{0}', value='{1}'", key, val);
78          #endif
79          Add( key, val );
80          key = null;
81          val = null;
82        }    
83      }
84    }
85    
86    

Legend:
Removed from v.1.1.2.1.2.1  
changed lines
  Added in v.1.1.2.1.2.2

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