private void NotifyConfObservers(string name)
 {
     if (confsObservers.ContainsKey(name))
     {
         ConfItem conf = this.confs[name];
         foreach (var c in confsObservers[name])
         {
             c(conf);
         }
     }
 }
        public void set(string name, object value, bool justMemory = false)
        {
            name = name.ToLower();
            //chekcs if the configuration is an enum
            ConfItem conf = new ConfItem();

            conf.Set(value);
            conf.justMemory = justMemory;
            confs[name]     = conf;
            WriteFile();
            NotifyConfObservers(name);
        }
        Dictionary <string, ConfItem> _ReadFileDefault(string fileName)
        {
            Dictionary <string, ConfItem> result = new Dictionary <string, ConfItem>();

            WriteFileSempahore.WaitOne();
            List <string> lines = new List <string>();

            if (File.Exists(fileName))
            {
                lines = File.ReadAllLines(fileName).ToList();
            }


            for (int cLines = 0; cLines < lines.Count; cLines++)
            {
                //check if line is not an comment or empty
                if ((lines[cLines] != "") && (!";#/\\".Contains(lines[cLines][0])))
                {
                    //checks if the line is a valid configuration
                    if (lines[cLines].Contains("="))
                    {
                        //take the name and the value of variable
                        string name = lines[cLines].Substring(0, lines[cLines].IndexOf('=')).TrimStart().TrimEnd().Trim();
                        name = name.Replace('_', '.').ToLower();

                        //take the value of variable
                        string value = lines[cLines].Substring(lines[cLines].IndexOf('=') + 1).TrimStart().TrimEnd().Trim();

                        result[name] = new ConfItem {
                            AsString = value
                        };
                    }
                }
            }

            //write the file
            WriteFileSempahore.Release();
            return(result);
        }
        public ConfItem get(string name, object defaultValue)
        {
            name = name.ToLower();
            //verify if the ram contains the variable
            if (confs.ContainsKey(name))
            {
                return(confs[name]);
            }
            else
            {
                //load file to ram
                ReadFile();

                //recheck the ram
                if (!confs.ContainsKey(name))
                {
                    ConfItem newConf = new ConfItem();
                    newConf.Set(defaultValue);
                    confs[name] = newConf;
                    WriteFile();
                }
                return(confs[name]);
            }
        }