Say we have:
class A
{
ILogger myLog;
A(ILogger log)
{
this.myLog = log;
}
...
}
And we have registered the ILogger interface before in the unity container, e.g.
container.RegisterType<ILogger, SomeLogger>();
And here the SomeLogger class:
class SomeLogger : ILogger
{
string myString;
SomeLogger(string test)
{
myString = test;
}
...
}
Now, how can unity create an instance of SomeLogger for class A without passing a string to the ctor of SomeLogger?
Suppose there is no other ctor for SomeLogger. Where can one specify the parameter(s) for ctor of the mapped SomeLogger type?
you could also do this in the registration code as follows: