DEV Community

loading...

Discussion on: Learn how YOU can manage your app configuration in ASP .NET Core

Collapse
softchris profile image
Chris Noring Author

hey.. Are you saying GetSection() and use bind() to a type isn't enough? One nice solution (that some libs use) is extension methods like so:

public static string GetMyProperty(this IConfiguration configuration)
    {
        string result = configuration.GetValue<string>("My:Key");
        return result;
    }

// usage
configuration.GetMyProperty() 
Enter fullscreen mode Exit fullscreen mode