Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

Add Options<T> #106

Closed
davidfowl opened this issue Jan 5, 2016 · 9 comments
Closed

Add Options<T> #106

davidfowl opened this issue Jan 5, 2016 · 9 comments
Assignees
Milestone

Comments

@davidfowl
Copy link
Member

Would act as an IOptions<T> wrapper for some T. Would make a convenient way to create an IOptions<T> from any T. We could also have a factory method (/cc @divega) that makes one of these from a T i.e. IOptions<T> Options.Create<T>(T options).

@davidfowl davidfowl added this to the 1.0.0-rc2 milestone Jan 5, 2016
@davidfowl davidfowl self-assigned this Jan 5, 2016
@HaoK
Copy link
Member

HaoK commented Jan 5, 2016

Would this would be instead of the old pattern of MyOptions implementing IOptions<MyOptions>?

@davidfowl
Copy link
Member Author

Yep! It's something @PinpointTownes suggested #105 (comment).

@davidfowl
Copy link
Member Author

I updated the sample in B to show the usage.

davidfowl added a commit that referenced this issue Jan 5, 2016
- Useful for passing poco TOptions to APIs that take IOptions<TOptions>
#106
@HaoK
Copy link
Member

HaoK commented Jan 5, 2016

Ok yeah that looks much better, it was pretty gross making everything implement IOptions before... Maybe we should name the generic Options class OptionsWrapper so people don't think its a base class...which is what the name implies...

@davidfowl
Copy link
Member Author

PR out for review.

@HaoK
Copy link
Member

HaoK commented Jan 5, 2016

Do we want to consider an overload of Options.Create<T>(Action<T> configure) just as pure sugar?

@davidfowl
Copy link
Member Author

Hmmmmmmmm

@davidfowl
Copy link
Member Author

app.UseFoo(Options.Create(options =>
{
    options.Value = 10;
});
var options = Options.Create(opt =>
{
  opt.Value = 10;
});

app.UseFoo(options);

@HaoK
Copy link
Member

HaoK commented Jan 5, 2016

Yeah well this way you give people the option to do either one, so everyone is happy

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

No branches or pull requests

2 participants