how to pass interface as constructor parameter? Can not do it with WithConstructorArgument

23 views
Skip to first unread message

spaceradar...@gmail.com

unread,
Dec 15, 2017, 5:16:02 AM12/15/17
to ninject
Can someone tell the equivalent to the snippet of code shown below in Ninject?

The code below is used with structuremap. It compiles ok
         For<IUserStore<SpaceRadarIdentityUser>>()
                .Use<SpaceRadar.Business.Layer.Repository.SpaceRadarUserStore>()
                .Ctor<ISpaceRadarDbContext>();



I tried using this snippet using Ninject but I got the errors listed following the code snippet
 container.Bind(typeof(IUserStore<SpaceRadarIdentityUser>))
.To(typeof(SpaceRadarUserStore))
.WithConstructorArgument(ISpaceRadarDbContext); 
The  ISpaceRadarDbContext parameter gives an error. . How can I get an interface to be passed or is that possible?


Error    CS0119    'ISpaceRadarDbContext' is a type, which is not valid in the given context    SpaceRadar.Web.Api    C:\spaceradarweb\spaceradarweb\SpaceRadar\SpaceRadar\src\SpaceRadar.Web.Api\App_Start\NinjectConfigurator.cs    167    Active

Bruno Juchli

unread,
Dec 15, 2017, 5:51:43 AM12/15/17
to ninject
This is not a structuremap experts list.

For 250$ per hour I'll convert your entire code base to use ninject instead of Structuremap.

If that sounds unreasonable then maybe instead of providing structuremap code you should provide an example of how this should look like using `new` operators.
Because i'm pretty sure all your questions can be easily answered by any Ninject "expert". If you provide the proper sample code.

spaceradar...@gmail.com

unread,
Dec 15, 2017, 10:48:00 PM12/15/17
to ninject
I already fixed it

spaceradar...@gmail.com

unread,
Dec 15, 2017, 10:48:39 PM12/15/17
to ninject
i already fixed it

On Friday, December 15, 2017 at 4:16:02 AM UTC-6, spaceradar...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages