In the Register
method the c
parameter is an instance of a IComponentContext
implementation which is the container in which the component is being created.
So the c
instance has all the necessary extension methods to resolve your previously registered types:
kernel.Register(c => {
var tokenHelper = c.Resolve<ITokenHelper>();
var httpContextBase = c.Resolve<HttpContextBase>();
var token = tokenHelper.GetToken(httpContextBase);
var connectionContext = c.Resolve<ISqlServerConnectionContext>();
connectionContext.Token = token;
return token;
}).As<IMinimalSecurityToken>();