Пример #1
0
        internal static void Serialize(PropertyAnalyzer analyzer, Dictionary<string, object> fieldDict)
        {
            if (analyzer == null)
                return;

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

            if (analyzer.Analyzer != null)
            {
                fieldDict.Add(_ANALYZER, analyzer.Analyzer.Name);
            }
            else
            {
                fieldDict.AddObject(_INDEX_ANALYZER, analyzer.IndexAnalyzer.Name);
                if(analyzer.SearchAnalyzer != null)
                {
                    fieldDict.AddObject(_SEARCH_ANALYZER, analyzer.SearchAnalyzer.Name);
                }                
            }
        }
Пример #2
0
        internal static PropertyAnalyzer Deserialize(Dictionary<string, object> fieldDict)
        {
            if (fieldDict == null || !fieldDict.Any())
                return null;

            PropertyAnalyzer propertyAnalyzer = null;
            if (fieldDict.ContainsKey(_ANALYZER))
            {
                propertyAnalyzer = new PropertyAnalyzer(GetAnalyzer(fieldDict.GetString(_ANALYZER)));
            }
            else if (fieldDict.ContainsKey(_INDEX_ANALYZER))
            {
                IAnalyzer searchAnalyzer = null;
                try 
                { 
                    searchAnalyzer = GetAnalyzer(fieldDict.GetStringOrDefault(_SEARCH_ANALYZER));
                }
                catch{}

                propertyAnalyzer = new PropertyAnalyzer(
                    GetAnalyzer(fieldDict.GetString(_INDEX_ANALYZER)),
                    searchAnalyzer);
            }

            return propertyAnalyzer;
        }