Example #1
0
        private void LoadConfigs()
        {
            Program.Logger.Info("Loading server configurations...");
            if (!File.Exists(ConfigFile))
            {
                throw new FileNotFoundException("Failed to load configs", ConfigFile);
            }

            using (var reader = new StreamReader(ConfigFile))
            {
                Program.Logger.Info("Parsing server configurations...");
                config = (ServerManagerConfiguration) new JsonSerializer().Deserialize(reader, typeof(ServerManagerConfiguration));
            }
        }
Example #2
0
        private void CreateConfigs()
        {
            Program.Logger.Info("Creating sample configuration files...");

            var cfg = new ServerConfiguration();

            cfg.Name             = "NanoDemo";
            cfg.RestartDelay     = 1;
            cfg.FilePath         = "nano";
            cfg.WorkingDirectory = "/home/" + Environment.UserName;
            cfg.Arguments        = "demo.txt";
            cfg.SendOnStart      = new string[]
            {
                "This ",
                "is ",
                "a ",
                "demo!^M"
            };
            cfg.SendOnStop = new string[]
            {
                "^X",
                "j",
                "^M"
            };

            var cfgs  = new ServerConfiguration[] { cfg };
            var smcfg = new ServerManagerConfiguration();

            smcfg.ServerConfigurations = cfgs;
            using (var writer = new StreamWriter(ConfigFile))
                new JsonSerializer()
                {
                    Formatting = Formatting.Indented
                }.Serialize(writer, smcfg);

            config = smcfg;
        }