Commits

Christian Specht  committed fe77fbd Draft

centralize default settings file name

  • Participants
  • Parent commits 87cd7c3

Comments (0)

Files changed (3)

File src/MissileSharp.Launcher/Services/ConfigService.cs

     /// </summary>
     public class ConfigService : IConfigService
     {
+        public string ConfigFileName
+        {
+            get { return "settings.txt"; }
+        }
+
         public string[] GetConfig()
         {
-            string configFile = "settings.txt";
-
-            if (!File.Exists(configFile))
+            if (!File.Exists(this.ConfigFileName))
             {
-                throw new FileNotFoundException(Resources.ConfigFileMissing + configFile);
+                throw new FileNotFoundException(Resources.ConfigFileMissing + this.ConfigFileName);
             }
 
-            var configFileLines = File.ReadAllLines(configFile);
+            var configFileLines = File.ReadAllLines(this.ConfigFileName);
 
             if (configFileLines.Length == 0)
             {
-                throw new FileFormatException(Resources.ConfigFileEmpty + configFile);
+                throw new FileFormatException(Resources.ConfigFileEmpty + this.ConfigFileName);
             }
 
             return configFileLines;

File src/MissileSharp.Launcher/Services/IConfigService.cs

     /// </summary>
     public interface IConfigService
     {
+        string ConfigFileName { get; }
         string[] GetConfig();
     }
 }

File src/MissileSharp.Launcher/ViewModels/MainWindowViewModel.cs

 
         private void OpenSettingsFile(Object obj)
         {
-            Process.Start("settings.txt");
+            Process.Start(this.configService.ConfigFileName);
         }
     }
 }