I am very new to Ninject and my scenario is this: I have two classes ClassA and ClassB with respective interfaces iClassA and iClassB . Classes are given below:
public ClassA()
{
private ClassB _clsb;
private String _trustKey;
public class ClassA(ClassB clsB)
{
_clsb = clsB;
}
public string getTrustKey()
{
this._trustKey = _clsb.trustKey
return this._trustKey;
}
}
public class ClassB()
{
private string _trustKey;
public ClassB(string trustkey)
{
_trustKey = trustKey;
}
public string trustKey()
{
get { return _trustKey; }
set { _trustKey = value; }
}
}
And I have a controller class and its constructor like this
public class controller : ApiController
{
private iClassA _iclsA;
public mycontroller(iClassA clsA)
{
_iclassA = clsA;
}
public string getTrustKey()
{
clsA.getTrustKey();
}
}
How can I initialize the trustkey value of ClassB at runtime so that when classA is called in the controller constructor, classB gets its trustkey initialized with runtime value. When i used kernel binding like kernel.bind<iclassA>.To<ClassA>()
and
kernel.bind<iClassB>.To<ClassB>()
, I could not assign a value to trustkey of classB.
Thanks in advanced!