Example #1
0
        public void Simple()
        {
            var storage = new EntityStorage();

            var guid1 = Guid.NewGuid();

            var obj1 = new TestObject()
            {
                Name = "Anton",
                Age = 27
            };
            obj1.SetId(guid1);
            obj1.State = TestEnum.STATE1;

            var x1 = storage.Put(obj1);

            var guid2 = Guid.NewGuid();

            var obj2 = new TestObject()
            {
                Name = "Vadim",
                FirstChild = obj1,
                Age = 55
            };
            obj2.SetId(guid2);
            obj2.Childs = new TestObject[] { obj2 };

            var x2 = storage.Put(obj2);

            var guid3 = Guid.NewGuid();

            var obj3 = new TestObject()
            {
                Name = "Irina",
                FirstChild = obj1,
                Age = 56
            };
            obj3.Childs = new List<TestObject> { };

            for (var i = 0; i < 1000; i++)
            {
                var obj = new TestObject()
                {
                    Name = "demo " + i,
                    FirstChild = obj1,
                    Age = 56
                };
                obj.SetId(Guid.NewGuid());
                obj3.Childs.Add(obj);
            }

            obj3.FirstChild = obj3;
            obj3.SetId(guid3);

            storage.Put(obj3);

            var obj4 = storage.Get(obj1);
            obj4.Age = 28;

            /*var test1 = new List<TestObject>() { obj1, obj2, obj3 };

            var storage2 = new MemoryStorage();

            storage2.Put(test1);
            obj1.Name = "Denis";
            obj1.Age = 40;
            storage2.Put(obj1);
            obj3.Name = "Ira Super";
            storage2.Put(obj3);

            var xxx1 = storage2.Get(obj3);
            xxx1.Name = "1";*/

            IList a = new string[] { };

            //int count = storage.cache.Count;
        }