Ejemplo n.º 1
0
 public Server(int port, IDictionaryReader reader)
 {
     server = new TcpListener(IPAddress.Loopback, port);
     server.Start();
     this.dictionaryReader = reader;
     new Thread(StartListener).Start();
 }
 public void Init()
 {
     m_dictionary = new Dictionary<object, string>
     {
         { Key, Value }
     };
     m_reader = m_dictionary.GetReader();
 }
Ejemplo n.º 3
0
 public IReader SetBuilders(
     IDictionaryReader dictionaryBuilder,
     IListReader listBuilder)
 {
     this.dictionaryBuilder = dictionaryBuilder;
     this.listBuilder       = listBuilder;
     return(this);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractParser"/> class.
 /// </summary>
 /// <param name="handlers">The handlers.</param>
 /// <param name="defaultHandler">The default handler.</param>
 /// <param name="dictionaryBuilder">The dictionary builder.</param>
 /// <param name="listBuilder">The list builder.</param>
 protected AbstractParser(IImmutableDictionary <string, IReadHandler> handlers,
                          IDefaultReadHandler <object> defaultHandler,
                          IDictionaryReader dictionaryBuilder,
                          IListReader listBuilder)
 {
     this.handlers          = handlers;
     this.defaultHandler    = defaultHandler;
     this.dictionaryBuilder = (IDictionaryReader)dictionaryBuilder;
     this.listBuilder       = (IListReader)listBuilder;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JsonParser"/> class.
 /// </summary>
 /// <param name="jsonTextReader">The json text reader.</param>
 /// <param name="handlers">The handlers.</param>
 /// <param name="defaultHandler">The default handler.</param>
 /// <param name="dictionaryBuilder">The dictionary builder.</param>
 /// <param name="listBuilder">The list builder.</param>
 public JsonParser(
     JsonTextReader jsonTextReader,
     IImmutableDictionary <string, IReadHandler> handlers,
     IDefaultReadHandler <object> defaultHandler,
     IDictionaryReader dictionaryBuilder,
     IListReader listBuilder)
     : base(handlers, defaultHandler, dictionaryBuilder, listBuilder)
 {
     this.jp = jsonTextReader;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractParser"/> class.
 /// </summary>
 /// <param name="handlers">The handlers.</param>
 /// <param name="defaultHandler">The default handler.</param>
 /// <param name="dictionaryBuilder">The dictionary builder.</param>
 /// <param name="listBuilder">The list builder.</param>
 protected AbstractParser(IImmutableDictionary<string, IReadHandler> handlers,
     IDefaultReadHandler<object> defaultHandler,
     IDictionaryReader dictionaryBuilder,
     IListReader listBuilder)
 {
     this.handlers = handlers;
     this.defaultHandler = defaultHandler;
     this.dictionaryBuilder = (IDictionaryReader)dictionaryBuilder;
     this.listBuilder = (IListReader)listBuilder;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JsonParser"/> class.
 /// </summary>
 /// <param name="jsonTextReader">The json text reader.</param>
 /// <param name="handlers">The handlers.</param>
 /// <param name="defaultHandler">The default handler.</param>
 /// <param name="dictionaryBuilder">The dictionary builder.</param>
 /// <param name="listBuilder">The list builder.</param>
 public JsonParser(
     JsonTextReader jsonTextReader,
     IImmutableDictionary<string, IReadHandler> handlers,
     IDefaultReadHandler<object> defaultHandler,
     IDictionaryReader dictionaryBuilder,
     IListReader listBuilder)
     : base(handlers, defaultHandler, dictionaryBuilder, listBuilder)
 {
     this.jp = jsonTextReader;
 }
Ejemplo n.º 8
0
            public IReader SetBuilders(IDictionaryReader dictionaryBuilder, IListReader listBuilder)
            {
                if (initialized)
                {
                    throw new TransitException("Cannot set builders after read has been called.");
                }

                this.dictionaryBuilder = dictionaryBuilder;
                this.listBuilder       = listBuilder;
                return(this);
            }
 public JSONDictionarySourceProvider(string name, IDictionaryReader reader, DictionaryConfiguration configuration = null)
 {
     _reader = reader;
     if (configuration == null)
     {
         configuration = DictionaryConfiguration.Default;
     }
     _dictionaryConfiguration = configuration;
     _dictionaries            = _reader.Initialize();
     // var _default = _dictionaries.FirstOrDefault(x => x.Value.Language.IsDefault == true);
     _defaultDictionarySource = _dictionaries.FirstOrDefault(x => x.Value.Language.IsDefault == true).Value; //_default != null ? _default.Value : null;
 }
Ejemplo n.º 10
0
            private void EnsureBuilders()
            {
                if (dictionaryBuilder == null)
                {
                    dictionaryBuilder = new DictionaryBuilder();
                }

                if (listBuilder == null)
                {
                    listBuilder = new ListBuilder();
                }
            }
Ejemplo n.º 11
0
        /// <summary>
        /// Parses the dictionary.
        /// </summary>
        /// <param name="ignored">if set to <c>true</c> [ignored].</param>
        /// <param name="cache">The cache.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="endToken">The end token.</param>
        /// <returns></returns>
        public object ParseDictionary(bool ignored, ReadCache cache, IDictionaryReadHandler handler, JsonToken endToken)
        {
            IDictionaryReader dr = (handler != null) ? handler.DictionaryReader() : dictionaryBuilder;

            object d = dr.Init();

            while (jp.NextToken() != endToken)
            {
                object key = ParseVal(true, cache);
                if (key is Tag)
                {
                    object val;
                    jp.Read(); // advance to read value
                    string       tag = ((Tag)key).GetValue();
                    IReadHandler val_handler;
                    if (TryGetHandler(tag, out val_handler))
                    {
                        if (this.jp.TokenType == JsonToken.StartObject && val_handler is IDictionaryReadHandler)
                        {
                            // use map reader to decode value
                            val = ParseDictionary(false, cache, (IDictionaryReadHandler)val_handler);
                        }
                        else if (this.jp.TokenType == JsonToken.StartArray && val_handler is IListReadHandler)
                        {
                            // use array reader to decode value
                            val = ParseList(false, cache, (IListReadHandler)val_handler);
                        }
                        else
                        {
                            // read value and decode normally
                            val = val_handler.FromRepresentation(ParseVal(false, cache));
                        }
                    }
                    else
                    {
                        // default decode
                        val = this.Decode(tag, ParseVal(false, cache));
                    }
                    jp.Read(); // advance to read end of object or array
                    return(val);
                }
                else
                {
                    jp.Read(); // advance to read value
                    d = dr.Add(d, key, ParseVal(false, cache));
                }
            }

            return(dr.Complete(d));
        }
Ejemplo n.º 12
0
        private static void ProcessInput(IDictionaryReader dictionaryReader)
        {
            var input = Input.ReadLineWithCancel();

            while (!string.IsNullOrWhiteSpace(input))
            {
                logger.Debug(input);
                var result = dictionaryReader
                             .GetMostFrequenciesWords(input, Count).ToList();
                result.ForEach(w => Console.WriteLine(w));
                Console.WriteLine();
                input = Input.ReadLineWithCancel();
            }
        }
Ejemplo n.º 13
0
 public GetWordsFunctionalService(IDictionaryReader dictionaryReader, GetWordsSettings settings)
 {
     this.dictionaryReader = dictionaryReader;
     this.settings         = settings;
 }
Ejemplo n.º 14
0
 public AnagramCheckerLibrary()
 {
     this.reader = new DictionaryReader();
 }
Ejemplo n.º 15
0
 public SpellCheckController(IDictionaryReader reader, IWordComparer comparer)
 {
     this.reader   = reader;
     this.comparer = comparer;
 }
 public KnownAnagramController(ILogger <KnownAnagramController> logger, IAnagramChecker checker, IDictionaryReader reader)
 {
     _logger  = logger;
     _checker = checker;
     _reader  = reader;
 }
Ejemplo n.º 17
0
 public AnagramSearcher(IDictionaryReader dictionaryReader)
 {
     _dictionaryReader = dictionaryReader;
 }
 //DictionaryFileReader dfr = new DictionaryFileReader(new IConfiguration);
 public AnagramCheckerDictionary(IDictionaryReader reader)
 {
     this.reader = reader;
 }
 public AnagramCheckerController(ILogger <AnagramCheckerController> logger, IDictionaryReader reader)
 {
     this.logger = logger;
     this.reader = reader;
 }
 public CachingDictionaryReader(IDictionaryReader innerReader)
 {
     this.innerReader = innerReader;
 }