Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
InterceptionBenchmark/InterceptionBenchmarks/UnityInterceptionBenchmark.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
33 lines (26 sloc)
970 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Practices.Unity; | |
using Microsoft.Practices.Unity.InterceptionExtension; | |
namespace InterceptionBenchmarks | |
{ | |
internal sealed class UnityInterceptionBenchmark | |
{ | |
private readonly UnityContainer _container; | |
public UnityInterceptionBenchmark() | |
{ | |
_container = new UnityContainer(); | |
_container.AddNewExtension<Interception>(); | |
_container.Configure<Interception>() | |
.AddPolicy("Metering") | |
.AddMatchingRule(new SingleMethodMatchingRule()) | |
.AddCallHandler(new UnityCallHandler()); | |
_container.RegisterType<ISomething, Something>( | |
new Interceptor<InterfaceInterceptor>(), | |
new InterceptionBehavior<PolicyInjectionBehavior>()); | |
} | |
public void Run() | |
{ | |
var something = _container.Resolve<ISomething>(); | |
something.Foo(); | |
} | |
} | |
} |