Binding error creating factory (Bug?)

21 views
Skip to first unread message

shaoli...@gmail.com

unread,
Feb 3, 2019, 5:05:43 PM2/3/19
to ninject
Hello,
I created a factory and I found a bug (?) if I name its interface method starting with "Get".
Example:

public interface IDashboardGiocatoreFactory

{

   IDashboardGiocatore GetOne(int id);

}


public interface IDashboardGiocatore

{

  ...

}


The api:


public HttpResponseMessage Get()

{

  var dg = _giocatoreFactory.GetOne(1);  <------ ERROR BINDING HERE

  

  return Request.CreateResponse(HttpStatusCode.OK);

}



Just renaming GetOne in something else (i renamed "CreateFactory") and it works!


Is there such a naming convention on it?


Thanks


Max

Mrinal Kamboj

unread,
Feb 10, 2019, 3:08:30 AM2/10/19
to nin...@googlegroups.com
Hi,

Can you provide little more details related to the Ninject binding for the IDashboardGiocatoreFactory, which would be used to call the GetOne method, which is leading to an error, also what's the error (No matching binding available). My assumption is you are using the Factory binding for the Ninject, which has CreateFactory as default, even if you rename as anything else like GetFactory, it would still fail.

Thanks,

Mrinal


--
You received this message because you are subscribed to the Google Groups "ninject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ninject+u...@googlegroups.com.
To post to this group, send email to nin...@googlegroups.com.
Visit this group at https://groups.google.com/group/ninject.
For more options, visit https://groups.google.com/d/optout.

shaoli...@gmail.com

unread,
Feb 10, 2019, 6:27:02 PM2/10/19
to ninject
CreateFactory works perfectly, is Getxxx the problem.
I recently found this:



Confirmed it was a naming convention!

Max

Mrinal Kamboj

unread,
Feb 11, 2019, 1:34:35 AM2/11/19
to nin...@googlegroups.com
Yes as you have correctly understood for calling anything like "Getxxx", would need a named binding to be created for the interface using "xxx" as named binding as explained at the links provided.
This special requirement is only for "Getxxx" methods.

Thanks,

Mrinal
Reply all
Reply to author
Forward
0 new messages