Esempio n. 1
0
        private ITokenizer BuildTokenizer(XmlNode tokenizerNode)
        {
            if (!tokenizerNode.Attributes.TryGetValueAsString("Name", out String tokenizerName, SmartSqlConfig.Properties))
            {
                throw new SmartSqlException("Tokenizer.Name can not be null.");
            }
            var properties = ParseProperties(tokenizerNode);

            return(_tokenizerBuilder.Build(tokenizerName, properties));
        }
Esempio n. 2
0
        // todo: not impl
        protected override void BuildAutoConverters()
        {
            if (_configOptions.AutoConverterBuilders == null || !_configOptions.AutoConverterBuilders.Any())
            {
                return;
            }

            foreach (var autoConverterBuilder in _configOptions.AutoConverterBuilders)
            {
                if (String.IsNullOrEmpty(autoConverterBuilder.Name))
                {
                    throw new SmartSqlException("AutoConverterBuilder.Name can not be null");
                }

                if (String.IsNullOrEmpty(autoConverterBuilder.TokenizerName))
                {
                    throw new SmartSqlException("AutoConverterBuilder.TokenizerName can not be null");
                }

                if (String.IsNullOrEmpty(autoConverterBuilder.WordsConverterName))
                {
                    throw new SmartSqlException("AutoConverterBuilder.WordsConverterName can not be null");
                }

                var tokenizer      = _tokenizerBuilder.Build(autoConverterBuilder.TokenizerName, autoConverterBuilder.TokenizerProperties);
                var wordsConverter = _wordsConverterBuilder.Build(autoConverterBuilder.WordsConverterName, autoConverterBuilder.WordsConverterProperties);

                var autoConverter = new AutoConverter.AutoConverter(autoConverterBuilder.Name, tokenizer, wordsConverter);

                SmartSqlConfig.AutoConverters.Add(autoConverter.Name, autoConverter);
                if (autoConverterBuilder.IsDefault)
                {
                    SmartSqlConfig.DefaultAutoConverter = autoConverter;
                }
            }
        }