示例#1
0
文件: Msg.cs 项目: Pasdedeux/LTool
        public Dictionary <K, V> GetParamDictionary <K, V>(object key)
        {
            Dictionary <Object, Object> input  = (Dictionary <Object, Object>)GetParam(key);
            DictionaryReader <K, V>     reader = new DictionaryReader <K, V>();

            return(reader.read(input));
        }
        static void Main(string[] args)
        {
            if (args.Length <= 0)
            {
                Console.WriteLine("invalid args");
                return;
            }
            switch (args[0])
            {
            case "check":
                if (args.Length <= 2)
                {
                    Console.WriteLine("invalid args");
                    return;
                }
                Console.WriteLine("\"{0}\" and \"{1}\" are {2}anagrams", args[0], args[1], new AnagramChecker().isAnagram(args[1], args[2]) ? "" : "no ");
                break;

            case "getKnown":
                if (args.Length <= 1)
                {
                    Console.WriteLine("invalid args");
                    return;
                }
                var config = new ConfigurationBuilder();
                config.AddJsonFile("config.json");
                config.AddEnvironmentVariables();
                var dr   = new DictionaryReader(config.Build());
                var dict = dr.read();
                var key  = new AnagramChecker().sortLetters(args[1]);
                if (dict.ContainsKey(key))
                {
                    foreach (var str in dict[key])
                    {
                        if (str.Equals(args[1]))
                        {
                            continue;
                        }
                        Console.WriteLine(str);
                    }
                }
                else
                {
                    Console.WriteLine("No known anagrams found");
                }
                break;

            default:
                Console.WriteLine("invalid args");
                break;
            }
        }