Beispiel #1
0
        public void AddAndRemovedEntriesFromDictionary()
        {
            var storage = new InMemoryStorageEngine();
            var os      = ObjectStore2.New(storage);
            var d       = new CDictionary <string, Person>();

            os.Roots.Entangle(d);

            d["101020"] = new Person {
                Name = "Peter"
            };
            d["311209"] = new Person {
                Name = "Ole", Relationship = d["101020"]
            };

            os.Persist();

            os = ObjectStore2.Load(storage);
            d  = os.Roots.Find <CDictionary <string, Person> >();

            d.Count.ShouldBe(2);
            d["101020"].Name.ShouldBe("Peter");
            d["101020"].Relationship.ShouldBeNull();

            d["311209"].Name.ShouldBe("Ole");
            d["311209"].Relationship.Name.ShouldBe("Peter");

            d.Remove("311209");

            os.Persist();
            os = ObjectStore2.Load(storage);
            d  = os.Roots.Find <CDictionary <string, Person> >();

            d.Count.ShouldBe(1);
            d["101020"].Name.ShouldBe("Peter");
            d["101020"].Relationship.ShouldBeNull();
            d["311209"] = d["101020"];

            os.Persist();
            os = ObjectStore2.Load(storage);
            d  = os.Roots.Find <CDictionary <string, Person> >();

            d.Count.ShouldBe(2);
            d["101020"].ShouldBe(d["311209"]);

            d.Remove("101020");
            d.Remove("311209");

            os.Persist();
            os = ObjectStore2.Load(storage);
            d  = os.Roots.Find <CDictionary <string, Person> >();

            d.Count.ShouldBe(0);
        }
Beispiel #2
0
 public void AckUntil(int until)
 {
     for (; Tail <= until; Tail++)
     {
         _unackedQueue.Remove(Tail);
     }
 }
Beispiel #3
0
            public bool Remove(Value aValue)
            {
                var aEntities = m_This.m_Entities;
                var aValues   = m_This.m_Values;
                var aEnd      = m_This.m_EndIndex;

                if (aValue == null)
                {
                    for (int i = 0; i < aEnd; ++i)
                    {
                        if (aEntities[i].m_Hashcode < 0)
                        {
                            continue;
                        }

                        if (aValues[i] == null)
                        {
                            return(m_This.Remove(aEntities[i].m_Key));
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < aEnd; ++i)
                    {
                        if (aEntities[i].m_Hashcode < 0)
                        {
                            continue;
                        }

                        if (aValue.Equals(aValues[i]))
                        {
                            return(m_This.Remove(aEntities[i].m_Key));
                        }
                    }
                }
                return(false);
            }
        public void InsertElementsPersistAndReceivedThemAgain()
        {
            var d = new CDictionary <int, string>
            {
                [5] = "Hello", [10] = "World"
            };


            AttachAndPersist(d);

            d = Load();
            d.Count.ShouldBe(2);
            d[5].ShouldBe("Hello");
            d[10].ShouldBe("World");

            d.Remove(5);
            Persist();

            d = Load();
            d.Count.ShouldBe(1);
            d[10].ShouldBe("World");

            d[10] = "WORLD";

            Persist();

            d = Load();

            d[10].ShouldBe("WORLD");

            d.Set(10, "worlds");
            d.Remove(10);

            Persist();

            d = Load();
            d.Count.ShouldBe(0);
        }
Beispiel #5
0
 /// <summary>
 /// 移除一个弹起键的钩子处理
 /// </summary>
 /// <param name="key">移除的按键</param>
 public static bool RemoveUp(Keys key)
 {
     return(handledKeysUp.Remove(key));
 }
Beispiel #6
0
 /// <summary>
 /// 移除一个按下键的钩子处理
 /// </summary>
 /// <param name="key">移除的按键</param>
 public static bool RemoveDown(Keys key)
 {
     return(handledKeysDown.Remove(key));
 }
Beispiel #7
0
 public static bool RemoveUp(Keys key)
 {
     return(cdictionary_1.Remove(key));
 }
Beispiel #8
0
 public static bool RemoveDown(Keys key)
 {
     return(cdictionary_0.Remove(key));
 }
Beispiel #9
0
 public bool Remove(Key aKey)
 {
     return(m_This.Remove(aKey));
 }