Hi. I saw that the Autofac SignalR integration docs say "due to SignalR internals, there is no support in SignalR for per-request lifetime dependencies." I had an idea to make this work using Castle DynamicProxy, and it turns out to work pretty well.
I've added a new method, RegisterHubWithLifetimeScope<T> that registers a dynamically generated subclass of T in place of T. When a Hub instance is requested, it creates a new implicit lifetime scope. The lifetime scope gets disposed when the owning Hub is disposed. The generated class is only loaded once so performance is good.
It all works because SignalR creates a new instance of the Hub for every operation.
Code is at github:
https://github.com/kingpong/Autofac.SignalR/compare/support-hub-lifetimescope
Any fatal flaws I'm overlooking? I'm interested to get this or something like it merged in at some point.
Thanks,
Philip