Exemplo n.º 1
0
        public void ExtTest()
        {
            var obj = new { state = 0, msg = "ddddd", data = new { test = "111", tds = "dsss" } };
            var timer01 = CodeTimer.Time("normal", 20 * 10000,
                () => { var str = new JavaScriptSerializer().Serialize(obj); });
            var timer02 = CodeTimer.Time("ext", 20 * 10000, () => { var str = obj.ToJson(); });

            Console.WriteLine(timer01.ToString());
            Console.WriteLine(timer02.ToString());
        }
Exemplo n.º 2
0
            public void ShouldImportProperties()
            {
                var obj = new
                {
                    IsSystem = true,
                    BlockTypeId = 1,
                    Zone = "TestZone",
                    Order = 3,
                    Name = "FooInstance",
                    OutputCacheDuration = 0
                };

                var json = obj.ToJson();
                var block = Block.FromJson( json );
                Assert.AreEqual( obj.Name, block.Name );
                Assert.AreEqual( obj.IsSystem, block.IsSystem );
            }
Exemplo n.º 3
0
            public void ShouldImportBlockType()
            {
                var obj = new
                    {
                        IsSystem = true,
                        BlockTypeId = 1,
                        Zone = "TestZone",
                        Order = 3,
                        Name = "FooInstance",
                        OutputCacheDuration = 0,
                        BlockType = new
                            {
                                IsSystem = false,
                                Path = "Test Path",
                                Name = "Test Name",
                                Description = "Test desc"
                            }
                    };

                var json = obj.ToJson();
                var block = Block.FromJson( json );
                var blockType = block.BlockType;
                Assert.IsNotNull( blockType );
                Assert.AreEqual( blockType.Name, obj.BlockType.Name );
            }