Пример #1
0
        static void Main(string[] args)
        {
            PrintArgs(args);

            var assemblyDir = typeof (Program).Assembly.GetAssemblyLocationFullPath();// Directory.GetCurrentDirectory();
            var tempDir = Path.Combine(assemblyDir, "temp");
            ClearDir(tempDir);

            ValidateArgs(args);
            var command = args[0];
            var configPath = Path.Combine(assemblyDir, command);
            if (!File.Exists(configPath))
            {
                throw new ArgumentException("config file does not exist, path: " + configPath);
            }

            IOutput output = new ConsoleOutput();
            IConfig config = new FileSimpleConfig(configPath);
            output.Write(config.ToString());

            if (command.In("publish-package-wa3-stable.cfg", "publish-package-walite-stable.cfg"))
            {
                var action = new PublishPackage(config, tempDir, output);
                action.Execute();
            }
            else
            {
                throw new ArgumentException("*.cfg file name does not match any supported config");
            }
        }
        void SetupWithOverrides()
        {
            File.WriteAllText(cfgPath, SampleConfig);
            File.WriteAllText(cfgUsrPath, OverrideConfig);

            config = new FileSimpleConfig(cfgPath);
        }
        public void PrintsConfig()
        {
            const string simpleConfig =
                @"#comment
key1=value1
key2=value2
";

//            const string expectedOutputPattern =
//@"Main config file\: .+\\config.cfg
//Override config file\: N/A
//Values\:
//KEY1\=value1
//KEY2\=value2
//End";

            using (DirectoryHandle tempDir1 = TempDirectoriesFactory.CreateEmpty())
            {
                var localCfgPath = Path.Combine(tempDir1.AbsolutePath, "config.cfg");
                File.WriteAllText(localCfgPath, simpleConfig);
                FileSimpleConfig localConfig = new FileSimpleConfig(localCfgPath);
                var result = localConfig.ToString();
                //verify manually if needed
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            PrintArgs(args);

            var assemblyDir = typeof(Program).Assembly.GetAssemblyLocationFullPath(); // Directory.GetCurrentDirectory();
            var tempDir     = Path.Combine(assemblyDir, "temp");

            ClearDir(tempDir);

            ValidateArgs(args);
            var command    = args[0];
            var configPath = Path.Combine(assemblyDir, command);

            if (!File.Exists(configPath))
            {
                throw new ArgumentException("config file does not exist, path: " + configPath);
            }

            IOutput output = new ConsoleOutput();
            IConfig config = new FileSimpleConfig(configPath);

            output.Write(config.ToString());

            var action = new PublishPackage(config, tempDir, output);

            action.Execute();
        }
 public void ValidatesInvalidLines()
 {
     foreach (var invalidCfg in InvalidCfgs)
     {
         File.WriteAllText(cfgPath, invalidCfg);
         Assert.Catch <Exception>(() => config = new FileSimpleConfig(cfgPath));
     }
 }
 public void ReadsOverridesFromDifferentLocation()
 {
     using (DirectoryHandle tempDir1 = TempDirectoriesFactory.CreateEmpty())
     {
         using (DirectoryHandle tempDir2 = TempDirectoriesFactory.CreateEmpty())
         {
             var localCfgPath    = Path.Combine(tempDir1.AbsolutePath, "config.cfg");
             var localCfgUsrPath = Path.Combine(tempDir2.AbsolutePath, "config.cfg.usr");
             File.WriteAllText(localCfgPath, SampleConfig);
             File.WriteAllText(localCfgUsrPath, OverrideConfig);
             FileSimpleConfig localConfig = new FileSimpleConfig(localCfgPath, localCfgUsrPath);
             Expect(localConfig.HasValue("key to be overriden"));
             Expect(localConfig.GetValue("key to be overriden"), EqualTo("overriden value"));
         }
     }
 }
Пример #7
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            HideHostWindow();

            var assemblyDir = Path.GetDirectoryName(this.GetType().Assembly.Location);
            if (assemblyDir == null)
            {
                throw new NullReferenceException("assemblyDir is null");
            }

            string configFileName = "debug.cfg";
            #if WA3STABLE
            configFileName = "wa3-stable.cfg";
            #endif
            #if WALITESTABLE
            configFileName = "walite-stable.cfg";
            #endif

            var settingsFile = Path.Combine(assemblyDir, configFileName);

            IConfig localSettings = new FileSimpleConfig(settingsFile);
            this.Text = localSettings.GetValue("AppName") + " Launcher";

            var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            var rootDir = Path.Combine(localAppData, "AldursLab", localSettings.GetValue("AldursLabDirName"));

            var config = new ControllerConfig()
            {
                RootDirFullPath = rootDir,
                WebServiceRootUrl = localSettings.GetValue("WebServiceRootUrl"),
                WurmAssistantExeFileName = localSettings.GetValue("WurmAssistantExeFileName")
            };

            IDebug debug = new TextDebug(Path.Combine(config.RootDirFullPath, "Launcher", "debug.txt"));
            debug.Clear();

            var controller = new LaunchController(this, config, debug);
            controller.Execute();
        }