Exemplo n.º 1
0
        internal static Norms Deserialize(Dictionary<string, object> fieldDict, bool isAnalyzed = true)
        {
            if (fieldDict == null || !fieldDict.ContainsKey(_NORMS))
                return null;

            Norms norms = new Norms();
            Dictionary<string, object> normsDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(fieldDict.GetString(_NORMS));
            if (isAnalyzed)
                norms.IsEnabled = normsDict.GetBool(_IS_ENABLED, _IS_ENABLED_ANALYZED_DEFAULT);
            else
                norms.IsEnabled = normsDict.GetBool(_IS_ENABLED, _IS_ENABLED_NOT_ANALYZED_DEFAULT);

            norms.Loading = NormLoadingEnum.Find(normsDict.GetString(_LOADING, _LOADING_DEFAULT.ToString()));

            return norms;
        }
Exemplo n.º 2
0
        internal static void Serialize(Norms norms, Dictionary<string, object> fieldDict, bool isAnalyzed = true)
        {
            if (norms == null)
                return;

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

            Dictionary<string, object> normsDict = new Dictionary<string, object>();

            if (isAnalyzed)
                normsDict.AddObject(_IS_ENABLED, norms.IsEnabled, _IS_ENABLED_ANALYZED_DEFAULT);
            else
                normsDict.AddObject(_IS_ENABLED, norms.IsEnabled, _IS_ENABLED_NOT_ANALYZED_DEFAULT);

            normsDict.AddObject(_LOADING, norms.Loading, _LOADING_DEFAULT);

            if (normsDict.Any())
                fieldDict.Add(_NORMS, normsDict);
        }