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

Support for Option Pattern #13

Open
timia2109 opened this issue Jun 9, 2024 · 1 comment
Open

Support for Option Pattern #13

timia2109 opened this issue Jun 9, 2024 · 1 comment

Comments

@timia2109
Copy link

Hi everyone,

it would be cool if you could add support for the Options Pattern.

If there is at least one class that uses the attribute, the generated method should be: serviceCollection.AutoRegister(IConfiguration configuration);

An attribute might look like this:

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class OptionAttribute : Attribute {
    public string? Section {get;}

    public OptionAttribute(string? section = null) {
        Section = section;
    }
}

Possible Usages:

[Option]
public record RootOption {}

[Option("SectionOption")]
public record SectionOption {}

[Option("SectionOption:InnerSection:MoreInnerSection")]
public record InnerSectionOption {}

Thank you

@patrickklaeren
Copy link
Owner

There are a number of considerations over both the surface area and extent to which ARI would be able to register options.

Mutability is quite a concern for a lot of people setting these types of objects up.

ARI would need to be able to new up one of these types, which isn't strictly what everyone wants. Since ARI is opinionated this may be ok.

There may be requirement to validate the options and as such provide more fine options within the attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants