我在我的asp.net Web API项目中使用迷你探查器,并希望跟踪在自定义DelegatingHandler中运行的某些代码的性能.
MiniProfiler.Current.Step()
内部的调用DelegatingHandler
不会显示在结果中.同一项目中的其他调用显示正常.
进一步的调查显示,MiniProfiler.Current
是从中获取HttpContext.Current
的WebRequestProfilerProvider
.而HttpContext.Current
从调用时为空 DelegatingHandler
.
有没有更好的方法来检索MiniProfiler.Current,以便它在处理程序内部工作?
我正在尝试使用以下选项在Mac OS X上的Mono上运行一个非常简单的Redis客户端:
var configOptions = new ConfigurationOptions()
{
EndPoints =
{
{ "localhost", 6379 },
},
ResolveDns = true,
KeepAlive = 180
};
StringWriter sw = new StringWriter();
ConnectionMultiplexer.Connect(configOptions, tw);
Run Code Online (Sandbox Code Playgroud)
它无法连接.这是跟踪:
localhost:6379,keepAlive=180,resolveDns=True
Using DNS to resolve 'localhost'...
'localhost' => 127.0.0.1
1 unique nodes specified
Requesting tie-break from 127.0.0.1:6379 > __Booksleeve_TieBreak...
Allowing endpoints 00:00:01 to respond...
127.0.0.1:6379 faulted: UnableToResolvePhysicalConnection on PING
127.0.0.1:6379 failed to nominate (Faulted)
> UnableToResolvePhysicalConnection on GET
No masters detected
127.0.0.1:6379: Standalone v2.0.0, master; keep-alive: 00:03:00; int: …
Run Code Online (Sandbox Code Playgroud) 我正在使用Autofac DynamicProxy2的接口拦截器,我能够为每个寄存器启用接口拦截器:
var registration = builder.RegisterType<AType>().As<AInterface>();
registration.EnableInterfaceInterceptors().InterceptedBy<AInterceptor>()
Run Code Online (Sandbox Code Playgroud)
我想对所有注册类型应用某些特征.就像是:
var registrations = builder.GetAllRegistrations(); // ops, this does not exist...
foreach (var registration in registrations) {
registration.EnableInterfaceInterceptors().InterceptedBy<AInterceptor>()
}
Run Code Online (Sandbox Code Playgroud)
我无法找到获得所有注册的方法.我知道我们可以这样做:
builder.RegisterCallback(cr =>
{
foreach (var registration in cr.Registrations)
{
// registration is IComponentRegistration
}
});
Run Code Online (Sandbox Code Playgroud)
但这里的注册是一个IComponentRegistration
,我需要一个IRegistrationBuilder
申请EnableInterfaceInterceptors()
.