Example #1
0
        internal static DocumentMapping Deserialize(Dictionary<string, object> fieldDict)
        {
            DocumentMapping mapping = new DocumentMapping();
            if (fieldDict.ContainsKey(_ALL))
                mapping.All = JsonConvert.DeserializeObject<All>(fieldDict.GetString(_ALL));
            if (fieldDict.ContainsKey(_ANALYZER))
                mapping.Analyzer = JsonConvert.DeserializeObject<DocumentAnalyzer>(fieldDict.GetString(_ANALYZER));
            if (fieldDict.ContainsKey(_ID))
                mapping.Id = JsonConvert.DeserializeObject<DocumentIdentifier>(fieldDict.GetString(_ID));
            if (fieldDict.ContainsKey(_INDEX))
                mapping.Index = JsonConvert.DeserializeObject<DocumentIndex>(fieldDict.GetString(_INDEX));
            if (fieldDict.ContainsKey(_PARENT))
                mapping.Parent = JsonConvert.DeserializeObject<ParentType>(fieldDict.GetString(_PARENT));
            if (fieldDict.ContainsKey(_ROUTING))
                mapping.Routing = JsonConvert.DeserializeObject<DocumentRouting>(fieldDict.GetString(_ROUTING));
            if (fieldDict.ContainsKey(_SIZE))
                mapping.Size = JsonConvert.DeserializeObject<DocumentSize>(fieldDict.GetString(_SIZE));
            if (fieldDict.ContainsKey(_SOURCE))
                mapping.Source = JsonConvert.DeserializeObject<DocumentSource>(fieldDict.GetString(_SOURCE));
            if (fieldDict.ContainsKey(_TIME_TO_LIVE))
                mapping.TimeToLive = JsonConvert.DeserializeObject<DocumentTimeToLive>(fieldDict.GetString(_TIME_TO_LIVE));
            if (fieldDict.ContainsKey(_TIMESTAMP))
                mapping.Timestamp = JsonConvert.DeserializeObject<DocumentTimestamp>(fieldDict.GetString(_TIMESTAMP));
            if (fieldDict.ContainsKey(_TYPE))
                mapping.Type = JsonConvert.DeserializeObject<DocumentType>(fieldDict.GetString(_TYPE));

            return mapping;
        }
Example #2
0
        internal static void Serialize(DocumentMapping fields, Dictionary<string, object> fieldDict)
        {
            if (fields == null)
                return;

            if (fieldDict == null)
                fieldDict = new Dictionary<string, object>();

            fieldDict.AddObject(_ID, fields.Id, _ID_DEFAULT);
            fieldDict.AddObject(_TYPE, fields.Type, _TYPE_DEFAULT);
            fieldDict.AddObject(_SOURCE, fields.Source, _SOURCE_DEFAULT);
            fieldDict.AddObject(_ALL, fields.All, _ALL_DEFAULT);
            fieldDict.AddObject(_ANALYZER, fields.Analyzer);
            fieldDict.AddObject(_PARENT, fields.Parent);
            fieldDict.AddObject(_ROUTING, fields.Routing, _ROUTING_DEFAULT);
            fieldDict.AddObject(_INDEX, fields.Index, _INDEX_DEFAULT);
            fieldDict.AddObject(_SIZE, fields.Size, _SIZE_DEFAULT);
            fieldDict.AddObject(_TIMESTAMP, fields.Timestamp, _TIMESTAMP_DEFAULT);
            fieldDict.AddObject(_TIME_TO_LIVE, fields.TimeToLive);
        }