コード例 #1
0
        /// <summary>
        /// Loads a Slob dictionary.
        /// </summary>
        /// <param name="fileName">Name of the dictionary file. The dictionary must be in SLOB format.</param>
        /// <param name="collectKeys">If set to <c>true</c>, the keys of all dictionaries will be collected. When loading multiple dictionaries subsequently, you should set this parameter to true only for the last dictionary loaded.</param>
        public void LoadDictionary(string fileName, bool collectKeys = true)
        {
            var slobReader = new SlobReaderWriter(fileName);
            var dictionary = slobReader.Read();

            dictionary.FileName = fileName;

            _dictionaries.Add(dictionary);

            if (collectKeys)
            {
                CollectAndSortKeys();
            }
        }
コード例 #2
0
        /// <summary>
        /// Loads a Slob dictionary.
        /// </summary>
        /// <param name="fileName">Name of the dictionary file. The dictionary must be in SLOB format.</param>
        /// <param name="collectKeys">If set to <c>true</c>, the keys of all dictionaries will be collected. When loading multiple dictionaries subsequently, you should set this parameter to true only for the last dictionary loaded.</param>
        public void LoadDictionary(string fileName, bool collectKeys = true)
        {
            var extension = System.IO.Path.GetExtension(fileName).ToLowerInvariant();

            IWordDictionary dictionary = null;

            switch (extension)
            {
            case ".ifo":
            {
                var starDict = new StarDict.StarDictionaryInMemory();
                starDict.Open(fileName);
                dictionary = starDict;
            }
            break;

            case ".slob":
            {
                var slobReader = new SlobReaderWriter(fileName);
                dictionary          = slobReader.Read();
                dictionary.FileName = fileName;
            }
            break;
            }


            if (null != dictionary)
            {
                _dictionaries.Add(dictionary);

                if (collectKeys)
                {
                    CollectAndSortKeys();
                }
            }
        }