You can register your call handler with Unity with a PerThreadLifetimeManager during startup.
_uC.RegisterType<LoggingCallHandler>(new PerThreadLifetimeManager());
Then the attribute can resolve the handler from the container:
public class LoggingAttribute : HandlerAttribute
{
public override ICallHandler CreateHandler(IUnityContainer container)
{
return container.Resolve<LoggingCallHandler>();
}
}
Usually, you don't want to pass around instances of the container since this tightly couples your application to the specific container used. This would be using the container as a Service Locator. Many people consider this to be an anti-pattern.
Call handler attributes are part of the Unity infrastructure (for your application); they extend Unity's abstract HandlerAttribute
and require the CreateHandler method to accept an IUnityContainer so using the container in the HandlerAttribute is not unexpected.