-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
Hey,
Is it possible to add support for returning the current state of the object being built by the builder class?
I'm aiming to implement something like this sample:
[FluentApi("{Name}Builder")]
public sealed class LoggerSettings
{
[FluentMember(0)]
public LogLevel MinimumLogLevel { get; init; }
[FluentMember(1)]
public FileLoggerConfiguration File { get; init; }
}Then on a separate class i declare a method that takes an action that relies on the generated builder to setup:
public class Logger
{
/// <summary>
/// Configures the static logger settings.
/// </summary>
/// <param name="configure">A delegate that defines the logic to configure the logger settings builder.</param>
public static void ConfigureLogger(Action<LoggerSettingsBuilder.ILoggerSettingsBuilder> configure)
{
var builder = LoggerSettingsBuilder.InitialStep();
configure(builder);
Settings = builder.Value();
}
}Value() would return the inner LoggerSettings object as it is and it so we can use it on wherever is necessary. The Value method would also be capable of being called whenever the current build step is.
I checked on other issues and found that something related was mentioned on #9, but applied to another scenario.
Metadata
Metadata
Assignees
Labels
No labels