Пример #1
0
        public void Invoke()
        {
            ItemNodeCofig itemNodeCofig = ConfigManager.GetConfigClass <ItemNodeCofig>();

            Console.WriteLine("Callback,:Node2:{0}", itemNodeCofig.Node2);
        }
Пример #2
0
        static void Main(string[] args)
        {
            try
            {
                ConfigManager.Init();
                //ConfigManager.Init(null, typeof(RedisProperties).Assembly);
                ConfigCallbackManager.RegisterCallback("node1", new NodeCallback("node1"));
                ConfigCallbackManager.RegisterCallback("node2", new NodeCallback("node2"));
                while (true)
                {
                    string cmd = Console.ReadLine();
                    if (string.IsNullOrWhiteSpace(cmd))
                    {
                        continue;
                    }
                    if (cmd == "print")
                    {
                        string json = ConfigStorageManager.PrintConfigItems();
                        Console.WriteLine(json);
                        continue;
                    }
                    if (cmd == "get redis.properties")
                    {
                        RedisProperties redisProperties = ConfigManager.GetConfigClass <RedisProperties>();
                        string          json            = redisProperties == null ? "" : JsonConvert.SerializeObject(redisProperties);
                        Console.WriteLine(json);
                        continue;
                    }

                    if (cmd == "get redis.config")
                    {
                        RedisConfig redisConfig = ConfigManager.GetConfigClass <RedisConfig>();
                        string      json        = redisConfig == null ? "" : JsonConvert.SerializeObject(redisConfig);
                        Console.WriteLine(json);
                        continue;
                    }

                    if (cmd == "get ItemNodeCofig")
                    {
                        ItemNodeCofig config = ConfigManager.GetConfigClass <ItemNodeCofig>();
                        string        json   = config == null ? "" : JsonConvert.SerializeObject(config);
                        Console.WriteLine(json);
                        continue;
                    }

                    if (cmd.StartsWith("get "))
                    {
                        string[] array = cmd.Split(' ');
                        if (array.Length == 2)
                        {
                            string key   = array[1];
                            string value = ConfigManager.GetConfigValue <string>(key);
                            Console.WriteLine(value);
                        }
                        continue;
                    }
                    if (cmd == "close")
                    {
                        ConfigStorageManager.CloseZooKeeperClient();
                        continue;
                    }
                    if (cmd == "clear")
                    {
                        Console.Clear();
                        continue;
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.GetLogger().Error(ex.Message, ex);
                Console.WriteLine(ex);
            }

            Console.ReadLine();
        }