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; } }
public WordsLoader(Configurator configurator) { this.configurator = configurator; }
public ConfigLoader() { fileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); config = LoadConfig(); }