ServiceStackのキャッシュ機能を使おうとしています。これらは、サービスのIOCによって挿入されるRequestContextを介してアクセスされます。
これは、デフォルトのFunq IOCを使用している場合は期待どおりに機能し、AutoFacをフックすると機能せず、RequestContextがnullであり、autofacを構成してビルドする方法がわかりません。ここに手がかりはありますか?私のAutoFac構成:
var builder = new ContainerBuilder();
//Now register all dependencies to your custom IoC container
builder.RegisterAssemblyTypes(new[] { typeof(AppHost).Assembly })
.PropertiesAutowired(PropertyWiringFlags.AllowCircularDependencies)
.AsImplementedInterfaces()
.SingleInstance();
container.Register<ICacheClient>(new MemoryCacheClient());
IContainerAdapter adapter = new AutofacIocAdapter(builder.Build());
container.Adapter = adapter;
編集:
私のサービスはすでにServiceStack.ServiceInterface.Serviceを拡張しています:
public class UserDetailsService : ServiceStack.ServiceInterface.Service
これはIRequiresRequestContextを実装し、RequestContextはnullです。autofacを削除すると、期待どおりに機能します。Autofacの場合RequestContextはnullです