Ninject - initialise objects
Posted
by James Lin
on Stack Overflow
See other posts from Stack Overflow
or by James Lin
Published on 2010-03-25T00:27:30Z
Indexed on
2010/03/25
0:33 UTC
Read the original article
Hit count: 498
Hi guys,
I am new to ninject, I am wondering how I can run custom initizlisation code when constructing the injected objects? ie. I have a Sword class which implements IWeapon, but I want to pass an hit point value to the Sword class constructor, how do I achieve that? Do I need to write my own provider?
A minor question, IKernel kernel = new StandardKernel(new Module1(), new Module2(), ...); what is the actual use of having multiple modules in Kernel? I sorta understand it, but could someone give me a formal explaination and use case?
Thanks a lot!
James
© Stack Overflow or respective owner