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