コード例 #1
0
 public void GetValue()
 {
     SetupWithOverrides();
     Expect(config.GetValue("key"), EqualTo("value"));
     Expect(config.GetValue("key2"), EqualTo("value2"));
     Expect(config.GetValue("key3"), EqualTo("value3"));
     Expect(config.GetValue("complex key"), EqualTo("complex value"));
     Expect(config.GetValue("case insensitive key"), EqualTo("Case Sensitive Value"));
     Expect(config.GetValue("key to be overriden"), EqualTo("overriden value"));
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: imtheman/WurmAssistant3
        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();
        }
コード例 #3
0
 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"));
         }
     }
 }