Exemplo n.º 1
0
        // ReSharper disable once InconsistentNaming
        private static void lookupAction(IBaseWorker w, IBaseOpt cmd, IEnumerable <string> args)
        {
            var enumerable = args.ToList();
            var mdxFile    = enumerable.ElementAtOrDefault(0);
            var word       = enumerable.ElementAtOrDefault(1);

            if (string.IsNullOrWhiteSpace(mdxFile))
            {
                w.ShowHelpScreen(w, enumerable);
                // w.ErrorPrint("no valid mdx file specified.");
                return;
            }

            var mdx = new MDictLoader(mdxFile);

            if (!mdx.Process())
            {
                // w.ErrorPrint($"CANNOT load and process the mdx file: {mdxFile}.");
                return;
            }

            Console.WriteLine($"<!--\n\nHeader: \n\n{mdx.DictHeader}\n\nIndex: \n\n{mdx.DictIndex}\n\n-->\n");

            if (!string.IsNullOrWhiteSpace(word))
            {
                // Console.WriteLine($"Lookup for word '{word}'...");
                // Console.WriteLine(word);
                var s = mdx.Query(word);
                Console.WriteLine(s);
            }
        }
Exemplo n.º 2
0
        // ReSharper disable once InconsistentNaming
        private static void listAction(IBaseWorker w, IBaseOpt cmd, IEnumerable <string> args)
        {
            var enumerable = args.ToList();
            var mdxFile    = enumerable.ElementAtOrDefault(0);
            var word       = enumerable.ElementAtOrDefault(1);

            if (string.IsNullOrWhiteSpace(mdxFile))
            {
                w.ShowHelpScreen(w, enumerable);
                // w.ErrorPrint("no valid mdx file specified.");
                return;
            }

            Console.WriteLine($"{mdxFile} / {word}");
            var mdx = new MDictLoader(mdxFile)
            {
                PreloadAll = true
            };

            if (!mdx.Process())
            {
                // w.ErrorPrint($"CANNOT load and process the mdx file: {mdxFile}.");
                return;
            }

            Console.WriteLine($"Header: \n\n{mdx.DictHeader}\n\nIndex: \n\n{mdx.DictIndex}\n\n");
        }
Exemplo n.º 3
0
        public void Invoke(IBaseWorker w, IEnumerable <string> remainsArgs)
        {
            var count = 0;

            foreach (var filename in remainsArgs)
            {
                count++;
                if (string.IsNullOrEmpty(filename))
                {
                    continue;
                }

                w.log.logInfo($"loading {filename} ...");
                using var l = new MDictLoader(filename);
                try
                {
                    l.Process();
                    Console.WriteLine($"header: {l.DictHeader}");
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.ToString());
                    // throw;
                }
                finally
                {
                    w.ParsedCount++;
                    // w.log.Information($"#{w.ParsedCount} parsed.");

                    // l.Dispose();
                }
            }

            if (count == 0)
            {
                w.ShowHelpScreen(w, remainsArgs.ToArray());
                return;
            }

            if (w.ParsedCount == 0)
            {
                w.log.logWarning(null, "Nothing to parsed.");
            }
        }