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

Rename IOptions<TOptions>.Options to .Value #31

Closed
davidfowl opened this issue Dec 13, 2014 · 7 comments
Closed

Rename IOptions<TOptions>.Options to .Value #31

davidfowl opened this issue Dec 13, 2014 · 7 comments

Comments

@davidfowl
Copy link
Member

Normally, you declare variables like this:

public class Foo
{
     private MyOptions _options;
     public Foo(IOptions<MyOptions> options)
     {
        _options = options.Value;
     }
}
@HaoK
Copy link
Member

HaoK commented Jul 20, 2015

@davidfowl @lodejard @divega with Named options being removed (soon), should we go back to IOptionsAccessor to match IHttpContextAccessor?

Or keep it IOptions and just switch it to IOptions.Value?

@brockallen
Copy link

Question related to this -- why can't MyOptions be injectable?

@HaoK
Copy link
Member

HaoK commented Jul 21, 2015

Options are meant to be simple poco data objects. I believe the motivations are similar to why configuration is not put into DI. But the actual initialization of options(IConfigureOptions) are.

@brockallen
Copy link

But IOptions<T>, in effect, is putting options into DI. I guess I don't understand the difference.

@HaoK
Copy link
Member

HaoK commented Jul 24, 2015

@divega @davidfowl What do you guys think about renaming IOptions to ISharedOptions to convey that this is meant to be used mostly when options are singletons/shared...

Its only property would be:

TOptions ISharedOptions.Value { get; }

@lodejard
Copy link

Lets keep the name IOptions. It started out as IOptionsAccessor which was inconveniently verbose.

@brockallen it is very similar, but the accessor service has advantages in that the creation of the singleton is deferred to when it's first used. Plus it enables the pattern where multiple IConfigureOptions can be added as services to alter any given TOptions. With a singleton MyOptions added to DI it must be fully baked before it is added, and the things doing the options configuration all need to do their work before IOC is available.

@HaoK HaoK self-assigned this Aug 11, 2015
@HaoK HaoK added this to the 1.0.0-beta7 milestone Aug 11, 2015
@HaoK HaoK modified the milestones: 1.0.0-beta8, 1.0.0-beta7 Sep 2, 2015
@HaoK HaoK added the 3 - Done label Sep 2, 2015
@HaoK
Copy link
Member

HaoK commented Sep 2, 2015

c623fbc

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

6 participants