예제 #1
0
 public static bool Load(IConfigurable target, string iniFile)
 {
     Debug.WriteLine("Loading configuration file " + iniFile);
     // Reset to default
     target.ResetParameters();
     try
     {
         // Load custom settings from INI file
         using (var ini = new IniReader(iniFile, true))
         {
             ini.AddHandler((x) =>
             {
                 if (target.AcceptsConfigs.Any(y => y == x.Group))
                 {
                     target.ApplyParameter(x);
                 }
             });
             ini.Parse();
         }
         return(true);
     }
     catch
     {
         Debug.WriteLine("Failed to load configuration from " + iniFile);
     }
     return(false);
     // DONE :)
 }
예제 #2
0
파일: Main.cs 프로젝트: nlhans/SimShift
        public static bool Load(IConfigurable target, string iniFile)
        {
            Debug.WriteLine("Loading configuration file " + iniFile);
            // Reset to default
            target.ResetParameters();
            try
            {
                // Load custom settings from INI file
                using (var ini = new IniReader(iniFile, true))
                {
                    ini.AddHandler((x) =>
                    {
                        if (target.AcceptsConfigs.Any(y => y == x.Group))
                        {
                            target.ApplyParameter(x);
                        }

                    });
                    ini.Parse();
                }
                return true;
            }
            catch
            {
                Debug.WriteLine("Failed to load configuration from " + iniFile);
            }
            return false;
            // DONE :)
        }