コード例 #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Dictionary<string, object> propDict = serializer.Deserialize<Dictionary<string, object>>(reader);
            LongProperty prop = new LongProperty(propDict.First().Key);
            NumberProperty.DeserializeNumber(prop, JsonConvert.DeserializeObject<Dictionary<string, object>>(propDict.First().Value.ToString()));

            return prop;
        }
コード例 #2
0
        public void PASS_Create()
        {
            LongProperty prop = new LongProperty("longme")
            {
                PrecisionStep = 5
            };

            Assert.IsNotNull(prop);
            Assert.AreEqual("longme", prop.Name);
            Assert.AreEqual((int)5, prop.PrecisionStep);
        }
コード例 #3
0
        public void PASS_Serialize()
        {
            LongProperty prop = new LongProperty("longme")
            {
                PrecisionStep = 5
            };
            string json = JsonConvert.SerializeObject(prop);
            Assert.IsNotNull(json);

            string expectedJson = "{\"longme\":{\"type\":\"long\",\"precision_step\":5}}";
            Assert.AreEqual(expectedJson, json);
        }