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

Add AutoCrossWireAspNetComponents overload that accepts IServiceProvider #585

Closed
dotnetjunkie opened this Issue Jul 11, 2018 · 1 comment

Comments

1 participant
@dotnetjunkie
Collaborator

dotnetjunkie commented Jul 11, 2018

Add an AutoCrossWireAspNetComponents(Container, IServiceProvider) overload to simplify working with ASP.NET Core v2.1 Generic Host. For more details, see #584.

@dotnetjunkie

This comment has been minimized.

Collaborator

dotnetjunkie commented Aug 6, 2018

In the meantime, to work around this, you will have to define your own IApplicationBuilder implementation that wraps your IServiceProvider. For instance:

public class ApplicationServicesWrapper : IApplicationBuilder
{
    public IServiceProvider ApplicationServices { get; set; }

    IFeatureCollection IApplicationBuilder.ServerFeatures => throw new Exception();
    IDictionary<string, object> IApplicationBuilder.Properties => throw new Exception();
    RequestDelegate IApplicationBuilder.Build() => throw new Exception();
    IApplicationBuilder IApplicationBuilder.New() => throw new Exception();
    IApplicationBuilder IApplicationBuilder.Use(Func<RequestDelegate, RequestDelegate> middleware) 
        => throw new Exception();
}

Using this wrapper, you can call AutoCrossWireAspNetComponents as follows:

container.AutoCrossWireAspNetComponents(
    new ApplicationServicesWrapper { ApplicationServices = serviceProvider });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment