public void SaveConfig(Configurator configurator)
 {
     using (StreamWriter sw = File.CreateText(fileName))
     {
         foreach (var p in configurator.GetType().GetProperties())
         {
             foreach (var attr in p.GetCustomAttributes())
             {
                 if (attr is Comment)
                 {
                     sw.WriteLine($"# {(attr as Comment).CommentText}");
                 }
                 if (attr is CommentEnum)
                 {
                     sw.Write($"# ");
                     foreach (var val in Enum.GetValues(p.PropertyType))
                     {
                         sw.Write($"{val}, ");
                     }
                     sw.Write("\n");
                 }
             }
             var a = p.GetValue(configurator).ToString();
             sw.WriteLine($"{p.Name}:{a}");
             if (p.Name == "AutoRun")
             {
                 if ((bool)p.GetValue(configurator))
                 {
                     AutoRunSet();
                 }
                 else
                 {
                     AutoRunUnset();
                 }
             }
         }
     }
 }
        private void SetValueToConfigurator(Configurator configurator, string key, string val)
        {
            PropertyInfo prop = null;

            foreach (var p in configurator.GetType().GetProperties())
            {
                if (key == p.Name)
                {
                    prop = p;
                    break;
                }
            }
            if (prop == null)
            {
                return;
            }
            var str = prop.PropertyType.Name;

            switch (str.ToLower())
            {
            case "string":
                prop.SetValue(configurator, val);
                break;

            case "int32":
                prop.SetValue(configurator, int.Parse(val));
                break;

            case "boolean":
                prop.SetValue(configurator, bool.Parse(val));
                break;

            case "askwordstype":
                prop.SetValue(configurator, Enum.Parse(typeof(AskWordsType), val));
                break;
            }
        }