Exemplo n.º 1
0
        private GatewayConfig GetValue(INIDocument doc)
        {
            GatewayConfig config = new GatewayConfig();

            doc.Load();
            Type clazz = config.GetType();

            foreach (INISection section in doc.Sections)
            {
                foreach (INIKey key in section.Keys)
                {
                    PropertyInfo pi    = clazz.GetProperty(key.Name);
                    object       value = key.Value;
                    if (pi.PropertyType == typeof(int))
                    {
                        value = Convert.ToInt32(value);
                    }
                    if (pi != null && !pi.PropertyType.IsGenericType)
                    {
                        pi.SetValue(config, value, null);
                    }
                }
            }
            return(config);
        }