/// <summary>
 /// Gibt die Serverconfig als weiterverarbeitbaren JSON String zurück.
 /// Parameter die einen NULL Wert haben, werden nicht zrückgeliefert, ebensowenig
 /// die Parameter die als ignore angegeben werden.
 /// BEispiel: var json = ConvertToJson("password");
 /// </summary>
 /// <param name="ignores">Parameter die ignoriert werden sollen und nicht mit in der JSON stehen sollen</param>
 /// <returns></returns>
 public string ConvertToJson(params string[] ignores)
 {
     if (ignores != null && ignores.Length > 0)
     {
         ServerCfgData returnedData = new ServerCfgData();
         var           memberlists  = typeof(ServerCfgData).GetProperties();
         if (memberlists != null)
         {
             foreach (var member in memberlists)
             {
                 if (ignores.Where(w => w.ToLower().Equals(member.Name.ToLower())).Count() == 0)
                 {
                     member.SetValue(returnedData, member.GetValue(servercfgData));
                 }
             }
         }
         return(JsonConvert.SerializeObject(returnedData, Formatting.Indented, new JsonSerializerSettings()
         {
             NullValueHandling = NullValueHandling.Ignore
         }));
     }
     else
     {
         return(JsonConvert.SerializeObject(servercfgData, Formatting.Indented, new JsonSerializerSettings()
         {
             NullValueHandling = NullValueHandling.Ignore
         }));
     }
 }
        /// <summary>
        /// Liest die server.config Datei ein und übergibt die Werte der Klasse
        /// ServerCfgData, welche wiederum über die Property GetServerConfig
        /// weiterverarbeitet werden kann.
        /// </summary>
        public void ParseFile()
        {
            var cfgFile = Path.Combine(rootPath, "server.cfg");

            if (File.Exists(cfgFile))
            {
                var content = File.ReadAllText(cfgFile);

                var datas = ParseData(content);
                if (datas != null)
                {
                    servercfgData = new ServerCfgData();

                    foreach (var kv in datas)
                    {
                        var members = typeof(ServerCfgData).GetProperty(kv.Key);
                        if (members != null)
                        {
                            if (members.PropertyType == typeof(String))
                            {
                                members.SetValue(servercfgData, kv.Value);
                            }
                            else if (members.PropertyType == typeof(short?))
                            {
                                short value;
                                if (short.TryParse(kv.Value, out value))
                                {
                                    members.SetValue(servercfgData, value);
                                }
                            }
                            else if (members.PropertyType == typeof(int?))
                            {
                                int value;
                                if (int.TryParse(kv.Value, out value))
                                {
                                    members.SetValue(servercfgData, value);
                                }
                            }
                            else if (members.PropertyType == typeof(bool?))
                            {
                                bool value;
                                if (bool.TryParse(kv.Value, out value))
                                {
                                    members.SetValue(servercfgData, value);
                                }
                            }
                            else if (members.PropertyType == typeof(List <string>))
                            {
                                //var memberdata = content.

                                var valSplitter = kv.Value.Split(new char[] { ',' });
                                if (valSplitter != null && valSplitter.Length > 0)
                                {
                                    List <string> list = new List <string>();
                                    foreach (var s in valSplitter)
                                    {
                                        list.Add(s.Trim());
                                    }
                                    members.SetValue(servercfgData, list);
                                }
                            }
                            else if (members.PropertyType == typeof(VoiceConfigObject))
                            {
                                VoiceConfigObject vco = new VoiceConfigObject();

                                var voiceSplitter = kv.Value.Split(new char[] { '\n' });
                                if (voiceSplitter != null && voiceSplitter.Length > 0)
                                {
                                    foreach (var v in voiceSplitter)
                                    {
                                        var vkpSplitter = v.Split(new char[] { ':' }, 2);
                                        if (vkpSplitter != null && vkpSplitter.Length == 2)
                                        {
                                            var voiceKey    = vkpSplitter[0].Trim();
                                            var voiceVal    = vkpSplitter[1].Trim().TrimEnd(new char[] { ',' });
                                            var voiceMember = typeof(VoiceConfigObject).GetProperty(voiceKey);
                                            if (voiceMember != null)
                                            {
                                                if (voiceMember.PropertyType == typeof(string))
                                                {
                                                    voiceMember.SetValue(vco, voiceVal);
                                                }
                                                else if (voiceMember.PropertyType == typeof(int?))
                                                {
                                                    int value;
                                                    if (int.TryParse(voiceVal, out value))
                                                    {
                                                        voiceMember.SetValue(vco, value);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    members.SetValue(servercfgData, vco);
                                }
                            }
                        }
                    }
                }
            }
        }