0
hitaspdotnet created
Hi, Can anyone here help me to migrate this from AutoFac to Windsor please?
private async Task ProcessEvent(string eventName, string message)
{
if (_subsManager.HasSubscriptionsForEvent(eventName))
{
using (var scope = _autofac.BeginLifetimeScope(AUTOFAC_SCOPE_NAME)) \\\ How can you do tag the scope in Windsor?
{
var subscriptions = _subsManager.GetHandlersForEvent(eventName);
foreach (var subscription in subscriptions)
{
if (subscription.IsDynamic)
{
var handler = scope.ResolveOptional(subscription.HandlerType) as IDynamicIntegrationEventHandler;
dynamic eventData = JObject.Parse(message);
await handler.Handle(eventData);
}
else
{
var eventType = _subsManager.GetEventTypeByName(eventName);
var integrationEvent = JsonConvert.DeserializeObject(message, eventType);
var handler = scope.ResolveOptional(subscription.HandlerType);
var concreteType = typeof(IIntegrationEventHandler<>).MakeGenericType(eventType);
await (Task)concreteType.GetMethod("Handle").Invoke(handler, new object[] { integrationEvent });
}
}
}
}
}
1 Answer(s)
-
0
Castle Windsor doesn't support tagged scopes: https://github.com/castleproject/Windsor/pull/351#issuecomment-359567747
If you just want a scope: https://aspnetboilerplate.com/Pages/Documents/Dependency-Injection#iiocresolver-iiocmanager-and-iscopediocresolver If you want a PerWebRequest lifestyle: https://stackoverflow.com/questions/49609763/how-to-make-use-of-castle-microkernel-registration-lifestyle-perwebrequest-within-abp