/// <summary> /// Returns the settings as a list of string map entries. /// </summary> /// <returns>The settings, as a list of string map entries.</returns> public String_StringMapEntry[] AsArray() { List<String_StringMapEntry> entries = new List<String_StringMapEntry>(); foreach (string key in values.Keys) { String_StringMapEntry entry = new String_StringMapEntry(); entry.key = key; entry.value = values[key]; entries.Add(entry); } return entries.ToArray(); }
public void TestAddEntry() { String_StringMapEntry item1 = new String_StringMapEntry(); item1.key = "key3"; item1.value = "value3"; mapUtils.AddEntry(item1); String_StringMapEntry item2 = new String_StringMapEntry(); item2.key = "key4"; item2.value = "value4"; mapUtils.AddEntry(item2); String_StringMapEntry[] entries = mapUtils.AsArray(); Assert.AreEqual(2, entries.Length); Assert.AreEqual(entries[0].key, item1.key); Assert.AreEqual(entries[0].value, item1.value); Assert.AreEqual(entries[1].key, item2.key); Assert.AreEqual(entries[1].value, item2.value); }
/// <summary> /// Adds an array of string map entries to the map. /// </summary> /// <param name="entries">The list of string map entries.</param> /// <returns>The maputils instance, for chaining calls.</returns> public MapUtilities AddEntries(String_StringMapEntry[] entries) { foreach (String_StringMapEntry entry in entries) { AddEntry(entry); } return this; }
/// <summary> /// Adds the specified string map entry to the map. /// </summary> /// <param name="entry">The string map entry.</param> /// <returns>The maputils instance, for chaining calls.</returns> public MapUtilities AddEntry(String_StringMapEntry entry) { values[entry.key] = entry.value; return this; }
public void TestAddEntries() { String_StringMapEntry item1 = new String_StringMapEntry(); item1.key = "key5"; item1.value = "value5"; String_StringMapEntry item2 = new String_StringMapEntry(); item2.key = "key6"; item2.value = "value6"; mapUtils.AddEntries(new String_StringMapEntry[] {item1, item2}); String_StringMapEntry[] entries = mapUtils.AsArray(); Assert.AreEqual(2, entries.Length); Assert.AreEqual(entries[0].key, item1.key); Assert.AreEqual(entries[0].value, item1.value); Assert.AreEqual(entries[1].key, item2.key); Assert.AreEqual(entries[1].value, item2.value); }
public void TestAsDict() { String_StringMapEntry item1 = new String_StringMapEntry(); item1.key = "key7"; item1.value = "value7"; String_StringMapEntry item2 = new String_StringMapEntry(); item2.key = "key8"; item2.value = "value8"; mapUtils.AddEntries(new String_StringMapEntry[] {item1, item2}); Dictionary<string, string> entries = mapUtils.AsDict(); Assert.AreEqual(2, entries.Count); Assert.True(entries.ContainsKey("key7")); Assert.True(entries.ContainsKey("key8")); Assert.AreEqual(entries["key7"], item1.value); Assert.AreEqual(entries["key8"], item2.value); }