Friday 15 May 2015

c# - Ninject factory not working with conventions for me -


I am trying to use the method of binding here, but there is no luck

Keep in mind that I am not trying to do this like this: instead I am trying to mean getmercedes conference (s)

I am basically trying to achieve it : With the conventions specified in the above examples.

  Using Ninject; Using Ninject.Extensions.Factory; Using Ninject.Moduleules; Using Ninject.Parameters; Using the system; Using System.Collections.Generic; Using System.Linq; Using the system. Using System.Text; System usage threading. Task; Namespace test. NinjectFactory {public-level program {public static zero main} ({var Colonel = New StandardCanel (New Carromode ()) {var factory = kernel.get & lt; ICarFactory & gt; (); Var Mercedes = Factory Gate Mercedes (); Int i = 1; }} Public Interface ICAR {Zero Drive (); } Public Class Mercedes: ICR [Read ICARF Factor Carfactor; Public Mercedes (ICARFFT Carfacture) {This. Factor = carfacture; } Public Zero Drive () {var Mercedes = this.carFactory.GetMercedes (); }} Public Interface ICAFactinator (ICR Getmersedus); } Public class car module: NinjaModel {public override zero load () {//http://github.com/ninject/ninject.extensions.factory/wiki/Factory-interface%3A-Referencing-Named-Binding Kernel.Bind & Lt; ICarFactory & gt; () ToFactory () .; Bound & lt; ICar & gt; (). & Lt; Mercedes & gt; (). NamedLikeFactoryMethod & lt; ICarFactory & gt; (X = & gt; x.GetMercedes ()); // do not work for me}}}}    

I think it's an answer form I am posting because it is the most likely reason.

Factory Prefix uses the prefix as a standard method to prefix the Go and NamedLikeFactoryMethod to any of your factory's methods. will participate in issues by calling. For example, go to GetFord , GetMercedes , GetNissan . You will see that, in the example on the link given by you, the function is called CreateMercedes .

The name of your function does not start with CreateMercedes or anything that gets and it should be fine.

No comments:

Post a Comment