Exemple #1
0
 public static string Get(string info)
 {
     try
     {
         return(_values[info]);
     }
     catch (Exception e)
     {
         SilverConsole.WriteLine(string.Format("Unable to find {0} in {1}", info, Constant.ConfigFile));
         return(null);
     }
 }
Exemple #2
0
 public static void LogWritter(string folder, string text)
 {
     lock (Lock)
     {
         try
         {
             using (var sw = new StreamWriter(string.Format("{0}/{1}", folder, FileName), true, Encoding.Default))
             {
                 sw.Write(text + Environment.NewLine);
             }
         }
         catch (Exception e)
         {
             SilverConsole.WriteLine(e.Message, ConsoleColor.Red);
         }
     }
 }
Exemple #3
0
        public static bool LoadConfig()
        {
            if (!File.Exists(Constant.ConfigFile))
            {
                SilverConsole.WriteLine("Error : Unable to find the file : " + Constant.ConfigFile, ConsoleColor.Red);
            }

            _values = new Dictionary <string, string>();

            try
            {
                using (var sr = new StreamReader(Constant.ConfigFile, Encoding.Default))
                {
                    while (!sr.EndOfStream)
                    {
                        var line = sr.ReadLine();

                        if (line == null || (line.Trim() == string.Empty || line.Trim().StartsWith("//")))
                        {
                            continue;
                        }

                        var infos = line.Split('=');
                        _values.Add(infos[0].Trim(), infos[1].Trim());
                    }

                    return(true);
                }
            }
            catch (Exception)
            {
                SilverConsole.WriteLine(string.Format("Error : {0} unreadable", Constant.ConfigFile), ConsoleColor.Red);

                return(false);
            }
        }