Can you pass lamda as your argument? For example, if you have a class like this:
public class Something : ISomething { public Something(Action<DateTime> initializer) { var now = initializer(); } }
You can link it as follows:
Bind<ISomething>() .To<Something>() .Using<OnePerSessionBehavior>() .WithArgument("initializer", () => { return DateTime.Now; });
Although I don't know the exact situation for you, another idea would be to create your object without worrying about entering arguments, and then set your properties:
kernel.Bind<ISomething>().To<Something>().Using<OnePerSessionBehavior>(); var mySomething = kernel.Get<Something>(); mySomething.DateCreated = DateTime.Now;
or
mySomething.Initialize(DateTime.Now);
Will any of these ideas work?
Mike Chamberlain Mar 01 2018-11-11T00: 00Z
source share