public void AddTest1() { tlog.Debug(tag, $"AddTest1 START"); try { ResourceDictionary t2 = new ResourceDictionary(); Assert.IsNotNull(t2, "null ResourceDictionary"); t2.Add("AA", "AA"); var ret = t2.ContainsKey("AA"); Assert.AreEqual(true, ret, "Should be equal"); var ret2 = t2["AA"]; Assert.AreEqual("AA", ret2, "Should be equal"); Assert.AreEqual(1, t2.Keys.Count, "Should be equal"); Assert.AreEqual(1, t2.Values.Count, "Should be equal"); Assert.IsNotNull(t2.GetEnumerator(), "null Enumerator"); object ss; t2.TryGetValue("AA", out ss); Assert.AreEqual("AA", ss as string, "Should be equal"); var ret3 = t2.Remove("AA"); Assert.True(ret3, "Should be true"); } catch (Exception e) { Assert.Fail("Caught Exception" + e.ToString()); } tlog.Debug(tag, $"AddTest1 END"); }
public static ContextMenu GetContextMenu( this ResourceDictionary resources, string templateName) { ContextMenu contextMenu = null; IDictionaryEnumerator e = resources.GetEnumerator(); while (e.MoveNext()) { DictionaryEntry entry = (DictionaryEntry)e.Current; string name = entry.Key as string; if (name == templateName) { contextMenu = entry.Value as ContextMenu; break; } } return(contextMenu); }