Ejemplo n.º 1
0
        private TestSerializerModel2 GetTestSerializerModel2()
        {
            Random rand = new Random();

            TestSerializerModel2 model = new TestSerializerModel2 {
                StringVal = "Fish"
            };

            if (rand.Next(1, 100) > 50)
            {
                model.DtValue = DateTime.Now;
            }

            if (rand.Next(1, 100) > 50)
            {
                model.IntVal = rand.Next(10, 100);
            }

            if (rand.Next(1, 100) > 50)
            {
                model.Money = Math.Round(1000M * (decimal)rand.NextDouble(), 4);
            }

            if (rand.Next(1, 100) > 50)
            {
                model.Guid = Guid.NewGuid();
            }

            s_lastTestSerializerModel2 = model;
            return(model);
        }
Ejemplo n.º 2
0
        public int Test3_AutoCheck(TestSerializerModel2 model)
        {
            //if( model.DtValue.HasValue && System.Web.HttpContext.Current.Request.ContentType.StartsWith("application/json") )
            //    model.DtValue = model.DtValue.Value.ToLocalTime();

            string xml1 = model.ToString();
            string xml2 = s_lastTestSerializerModel2.ToString();

            return(xml1 == xml2 ? 1 : 0);
        }
Ejemplo n.º 3
0
        public int Test4_AutoCheck(string stringVal, int?intVal, DateTime?dtValue, decimal?money, Guid?guid)
        {
            //if( dtValue.HasValue && System.Web.HttpContext.Current.Request.ContentType.StartsWith("application/json") )
            //    dtValue = dtValue.Value.ToLocalTime();

            TestSerializerModel2 model = TestSerializerModel2.Create(stringVal, intVal, dtValue, money, guid);

            string xml1 = model.ToString();
            string xml2 = s_lastTestSerializerModel2.ToString();

            return(xml1 == xml2 ? 1 : 0);
        }
Ejemplo n.º 4
0
        public string Test4(string stringVal, int?intVal, DateTime?dtValue, decimal?money, Guid?guid)
        {
            TestSerializerModel2 model = TestSerializerModel2.Create(stringVal, intVal, dtValue, money, guid);

            return(model.ToString());
        }
Ejemplo n.º 5
0
 public string Test3(TestSerializerModel2 model)
 {
     return(model.ToString());
 }
Ejemplo n.º 6
0
        public object GetJson2()
        {
            TestSerializerModel2 model = GetTestSerializerModel2();

            return(new JsonResult(model));
        }
Ejemplo n.º 7
0
        public object GetXml2()
        {
            TestSerializerModel2 model = GetTestSerializerModel2();

            return(new XmlResult(model));
        }