Apache.NMS.Util.PrimitiveMap.GetByte C# (CSharp) Method

GetByte() public method

public GetByte ( String key ) : byte
key String
return byte
        public byte GetByte(String key)
        {
            Object value = GetValue(key);
            CheckValueType(value, typeof(byte));
            return (byte) value;
        }

Usage Example

Beispiel #1
0
		protected void AssertPrimitiveMap(PrimitiveMap map)
		{
			// use generic API to access entries
			Assert.AreEqual(a, map["a"], "generic map entry: a");
			Assert.AreEqual(b, map["b"], "generic map entry: b");
			Assert.AreEqual(c, map["c"], "generic map entry: c");
			Assert.AreEqual(d, map["d"], "generic map entry: d");
			Assert.AreEqual(e, map["e"], "generic map entry: e");
			Assert.AreEqual(f, map["f"], "generic map entry: f");
			Assert.AreEqual(g, map["g"], "generic map entry: g");
			Assert.AreEqual(h, map["h"], "generic map entry: h");
			Assert.AreEqual(i, map["i"], "generic map entry: i");
			Assert.AreEqual(j, map["j"], "generic map entry: j");
			Assert.AreEqual(k, map["k"], "generic map entry: k");
			Assert.AreEqual(l, map["l"], "generic map entry: l");
			//Assert.AreEqual(m, map["m"], "generic map entry: m");
			//Assert.AreEqual(n, map["n"], "generic map entry: n");

			// use type safe APIs
			Assert.AreEqual(a, map.GetBool("a"), "map entry: a");
			Assert.AreEqual(b, map.GetByte("b"), "map entry: b");
			Assert.AreEqual(c, map.GetChar("c"), "map entry: c");
			Assert.AreEqual(d, map.GetShort("d"), "map entry: d");
			Assert.AreEqual(e, map.GetInt("e"), "map entry: e");
			Assert.AreEqual(f, map.GetLong("f"), "map entry: f");
			Assert.AreEqual(g, map.GetString("g"), "map entry: g");
			Assert.AreEqual(h, map.GetBool("h"), "map entry: h");
			Assert.AreEqual(i, map.GetByte("i"), "map entry: i");
			Assert.AreEqual(j, map.GetShort("j"), "map entry: j");
			Assert.AreEqual(k, map.GetInt("k"), "map entry: k");
			Assert.AreEqual(l, map.GetLong("l"), "map entry: l");
			//Assert.AreEqual(m, map.GetList("m"), "map entry: m");
			//Assert.AreEqual(n, map.GetDictionary("n"), "map entry: n");

			IList list = map.GetList("m");
			Assert.AreEqual(2, list.Count, "list size");
			Assert.IsTrue(list.Contains("Item1"));
			Assert.IsTrue(list.Contains("Item2"));

			IDictionary dictionary = map.GetDictionary("n");
			Assert.AreEqual(5, dictionary.Count, "dictionary size");

			IDictionary childMap = (IDictionary) dictionary["childMap"];
			Assert.IsNotNull(childMap);
			Assert.AreEqual("childMap", childMap["name"], "childMap[name]");

			IList childList = (IList) dictionary["childList"];
			Assert.IsNotNull(childList);
			Assert.IsTrue(childList.Contains("childListElement1"));
		}