Exemple #1
0
        public void OrderingEnumerator()
        {
            var xps = new XmlRpcStruct();

            xps.Add("1", "a");
            xps.Add("3", "c");
            xps.Add("2", "b");
            IDictionaryEnumerator enumerator = xps.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("1", enumerator.Key);
            Assert.AreEqual("a", enumerator.Value);
            Assert.IsInstanceOf(typeof(DictionaryEntry), enumerator.Current);
            DictionaryEntry de = (DictionaryEntry)enumerator.Current;

            Assert.AreEqual("1", de.Key);
            Assert.AreEqual("a", de.Value);
            enumerator.MoveNext();
            Assert.AreEqual("3", enumerator.Key);
            Assert.AreEqual("c", enumerator.Value);
            Assert.IsInstanceOf(typeof(DictionaryEntry), enumerator.Current);
            de = (DictionaryEntry)enumerator.Current;
            Assert.AreEqual("3", de.Key);
            Assert.AreEqual("c", de.Value);
            enumerator.MoveNext();
            Assert.AreEqual("2", enumerator.Key);
            Assert.AreEqual("b", enumerator.Value);
            Assert.IsInstanceOf(typeof(DictionaryEntry), enumerator.Current);
            de = (DictionaryEntry)enumerator.Current;
            Assert.AreEqual("2", de.Key);
            Assert.AreEqual("b", de.Value);
        }
Exemple #2
0
        public void OrderingEnumerator()
        {
            var xps = new XmlRpcStruct {
                { "1", "a" },
                { "3", "c" },
                { "2", "b" }
            };
            var enumerator = xps.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("1", enumerator.Current.Key);
            Assert.AreEqual("a", enumerator.Current.Value);
            Assert.IsInstanceOf <KeyValuePair <string, object> >(enumerator.Current);
            var de = enumerator.Current;

            Assert.AreEqual("1", de.Key);
            Assert.AreEqual("a", de.Value);
            enumerator.MoveNext();
            Assert.AreEqual("3", enumerator.Current.Key);
            Assert.AreEqual("c", enumerator.Current.Value);
            Assert.IsInstanceOf <KeyValuePair <string, object> >(enumerator.Current);
            de = enumerator.Current;
            Assert.AreEqual("3", de.Key);
            Assert.AreEqual("c", de.Value);
            enumerator.MoveNext();
            Assert.AreEqual("2", enumerator.Current.Key);
            Assert.AreEqual("b", enumerator.Current.Value);
            Assert.IsInstanceOf <KeyValuePair <string, object> >(enumerator.Current);
            de = enumerator.Current;
            Assert.AreEqual("2", de.Key);
            Assert.AreEqual("b", de.Value);
        }
Exemple #3
0
        protected override Dictionary <string, object> DoGetServerStatistics()
        {
            Dictionary <string, object> retVal = new Dictionary <string, object>();

            XmlRpcStruct rsp = _client.GetServerInfo2();

            if (rsp != null)
            {
                IDictionaryEnumerator iter = rsp.GetEnumerator();
                while (iter.MoveNext())
                {
                    if (iter.Key != null)
                    {
                        if (retVal.ContainsKey(iter.Key.ToString()))
                        {
                            retVal[iter.Key.ToString()] = iter.Value;
                        }
                        else
                        {
                            retVal.Add(iter.Key.ToString(), iter.Value);
                        }
                    }
                }
            }

            return(retVal);
        }
Exemple #4
0
        public void XmlRpcStructOrder()
        {
            Type   parsedType, parsedArrayType;
            string xml = @"<?xml version=""1.0"" ?>
<value>
  <struct>
    <member>
      <name>a</name>
      <value><i4>1</i4></value>
    </member>
    <member>
      <name>c</name>
      <value><i4>3</i4></value>
    </member>
    <member>
      <name>b</name>
      <value><i4>2</i4></value>
    </member>
  </struct>
</value>";
            object obj = Utils.Parse(xml, typeof(XmlRpcStruct), MappingAction.Error,
                                     out parsedType, out parsedArrayType);

            Assert.IsInstanceOfType(typeof(XmlRpcStruct), obj);
            XmlRpcStruct          strct       = obj as XmlRpcStruct;
            IDictionaryEnumerator denumerator = strct.GetEnumerator();

            denumerator.MoveNext();
            Assert.AreEqual("a", denumerator.Key);
            Assert.AreEqual(1, denumerator.Value);
            denumerator.MoveNext();
            Assert.AreEqual("c", denumerator.Key);
            Assert.AreEqual(3, denumerator.Value);
            denumerator.MoveNext();
            Assert.AreEqual("b", denumerator.Key);
            Assert.AreEqual(2, denumerator.Value);
        }