Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added configuration manager to PhotinoBlazorAppBuilder #86

Closed

Conversation

En3Tho
Copy link

@En3Tho En3Tho commented Jun 14, 2023

I was very surprised PhotinoBlazorAppBuilder didn't have a ConfigurationManager considering many other builders have one.
E.g.:

public sealed class MauiAppBuilder
{
    /// <summary>
    /// A collection of configuration providers for the application to compose. This is useful for adding new configuration sources and providers.
    /// </summary>
    public ConfigurationManager Configuration { get; }
}

public sealed class WebApplicationBuilder
{
    /// <summary>
    /// Initial configuration sources to be added to the <see cref="HostApplicationBuilder.Configuration"/>. These sources can influence
    /// the <see cref="HostApplicationBuilder.Environment"/> through the use of <see cref="HostDefaults"/> keys. Disposing the built
    /// <see cref="IHost"/> disposes the <see cref="ConfigurationManager"/>.
    /// </summary>
    public ConfigurationManager? Configuration { get; set; }
}

public sealed class WebAssemblyHostBuilder // this one is a special one but it has one too
{
    /// <summary>
    /// Gets an <see cref="WebAssemblyHostConfiguration"/> that can be used to customize the application's
    /// configuration sources and read configuration attributes.
    /// </summary>
    public WebAssemblyHostConfiguration Configuration { get; }
}

This also will help a little to implement new IHostApplicationBuilder interface introduced in .Net 8 (dotnet/runtime#86974)

@ottodobretsberger ottodobretsberger added the question Further information is requested label Jun 15, 2023
@ottodobretsberger
Copy link
Contributor

Would you mind elaborating on a specific use case where this will come in handy?

@En3Tho
Copy link
Author

En3Tho commented Jun 15, 2023

This is a standard way in AspNetCore/Blazor/modern .Net hosting model to get configuration values. e.g. connection strings, urls, secrets etc. This improves builder so that in can be used in a similar way to WebAssemblyBuilder or MauiBuilder. Otherwise it just has to be created manually.

I think these should be added too to match the new IHostApplicationBuilder interface (I belive all .Net HostApplicationBuilders will inherit this one)

Microsoft.Extensions.Hosting.IHostEnvironment Environment { get; }
Microsoft.Extensions.Logging.ILoggingBuilder Logging { get; }

This just enables more code sharing between different hosting models while having less friction

@En3Tho En3Tho closed this Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants