예제 #1
0
        public void PASS_Create()
        {
            TokenCountProperty prop = new TokenCountProperty("tokencountme", "count-analyzer");

            Assert.IsNotNull(prop);
            Assert.AreEqual("tokencountme", prop.Name);
            Assert.AreEqual("count-analyzer", prop.Analyzer);
        }
예제 #2
0
        public void PASS_Serialize()
        {
            TokenCountProperty prop = new TokenCountProperty("tokencountme", "count-analyzer");
            string json = JsonConvert.SerializeObject(prop);
            Assert.IsNotNull(json);

            string expectedJson = "{\"tokencountme\":{\"type\":\"token_count\",\"analyzer\":\"count-analyzer\"}}";
            Assert.AreEqual(expectedJson, json);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Dictionary<string, object> propDict = serializer.Deserialize<Dictionary<string, object>>(reader);
            Dictionary<string, object> fieldDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(propDict.First().Value.ToString());

            TokenCountProperty prop = new TokenCountProperty(propDict.First().Key, fieldDict.GetString(_ANALYZER));
            NumberProperty.DeserializeNumber(prop, fieldDict);

            return prop;
        }