title: Map appsettings.json to class
body: <p>I'm trying to convert appsettings.json to C# class</p>
  <p>I use <code>Microsoft.Extensions.Configuration</code> to read the configuration from appsettings.json</p>
  <p>I write the following code using reflection but I'm looking for a better solution</p>
  <pre><code>foreach (var (key, value) in configuration.AsEnumerable())
  {
      var property = Settings.GetType().GetProperty(key);
      if (property == null) continue;
      
      object obj = value;
      if (property.PropertyType.FullName == typeof(int).FullName)
          obj = int.Parse(value);
      if (property.PropertyType.FullName == typeof(long).FullName)
          obj = long.Parse(value);
      property.SetValue(Settings, obj);
  }
  </code></pre>