public void FixToActive(EmercoinConfig config)
 {
     config.SetParameter(EmercoinConfig.serverParam, "1");
     config.SetParameter(EmercoinConfig.listenParam, "1");
     config.SetParameter(EmercoinConfig.userParam, "rpcemc");
     config.SetParameter(EmercoinConfig.rpcPasswordParam, randomString(6));
     config.SetParameter(EmercoinConfig.debugParam, "rpc");
     config.SetParameter(EmercoinConfig.portParam, "6662");
 }
        public EmercoinConfig ReadConfig()
        {
            var config = new EmercoinConfig();

            int lineId = 0;

            foreach (var l in this.lines)
            {
                var param = this.parseLine(l, lineId);
                if (param != null && !config.Parameters.ContainsKey(param.Name))
                {
                    config.Parameters.Add(param.Name, param);
                }
                lineId++;
            }

            return(config);
        }
        public void WriteConfig(EmercoinConfig config, string filePath)
        {
            if (string.IsNullOrWhiteSpace(filePath))
            {
                throw new Exception("Invalid file path");
            }

            foreach (var p in config.Parameters.Values)
            {
                // adding new values into the end of the list
                // changing existing values
                if (p.LineId == -1)
                {
                    this.lines.Add(p.ToString());
                }
                else
                {
                    this.lines[p.LineId] = p.ToString();
                }
            }

            File.WriteAllLines(filePath, this.lines);
        }