, , :
var workflowRegistrationCache = new MemoryCache("workflow");
container.Register<IWorkflowRegistrationService>(
() => new WorkflowRegistrationService(workflowRegistrationCache));
var migrationRegistrationCache = new MemoryCache("migration");
container.Register<IMigrationRegistrationService>(
() => new MigrationRegistrationService(
container.GetInstance<ISomeService>(),
migrationRegistrationCache));
. , , :
var workflowRegistrationCache = new MemoryCache("workflow");
var migrationRegistrationCache = new MemoryCache("migration");
container.RegisterWithContext<MemoryCache>(context =>
{
return context.ServiceType == typeof(IWorkflowRegistrationService)
? workflowRegistrationCache
: migrationRegistrationCache;
});
container.Register<IWorkflowRegistrationService, WorkflowRegistrationService>();
container.Register<IMigrationRegistrationService, MigrationRegistrationService>();
WorkflowRegistrationService MigrationRegistrationService , .
, , . fooobar.com/questions/1510262/... .