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

Consider switching to IConfigureOptions instead of ConfigureOptions in OptionsSetup #4736

Closed
pranavkm opened this issue May 24, 2016 · 4 comments
Assignees

Comments

@pranavkm
Copy link
Contributor

pranavkm commented May 24, 2016

The API for using IConfigureOptions<> is a bit more traditional than using the lambda overload that ConfigureOptions<> has:

Consider what we have

public class MvcCoreRouteOptionsSetup : ConfigureOptions<RouteOptions>
{
    public MvcCoreRouteOptionsSetup()
        : base(ConfigureRouting)
    {
    }

    public static void ConfigureRouting(RouteOptions options)
    {
        options.ConstraintMap.Add("exists", typeof(KnownRouteValueConstraint));
    }
}

versus

public class MvcCoreRouteOptionsSetup : IConfigureOptions<RouteOptions>
{
    public void Configure(RouteOptions options)
    {
        options.ConstraintMap.Add("exists", typeof(KnownRouteValueConstraint));
    }
}
@rynowak
Copy link
Member

rynowak commented May 24, 2016

FYI , I asked @pranavkm to file this, it's just code cleanup. The ConfigureOptions base class is kludgy to use when you have constructor parameters

@Eilon
Copy link
Member

Eilon commented May 24, 2016

The type MvcCoreRouteOptionsSetup is in a .Internal namespace. Can we clean this up later?

@rynowak
Copy link
Member

rynowak commented May 24, 2016

We can do this like 10 years from now 😆

@Eilon Eilon added this to the 1.0.1 milestone May 24, 2016
@Eilon
Copy link
Member

Eilon commented May 24, 2016

Got it.

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

4 participants