Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/PolicyInjection/Pipeline/PipelineManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@


using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Reflection;
using Unity.Interception.Interceptors;
Expand All @@ -19,6 +20,9 @@ public class PipelineManager

private static readonly HandlerPipeline EmptyPipeline = new HandlerPipeline();

private static readonly ConcurrentDictionary<HandlerPipelineKey, MethodInfo> BaseMethodDefinitions =
new ConcurrentDictionary<HandlerPipelineKey, MethodInfo>();

/// <summary>
/// Retrieve the pipeline associated with the requested <paramref name="method"/>.
/// </summary>
Expand Down Expand Up @@ -74,13 +78,15 @@ private HandlerPipeline CreatePipeline(MethodInfo method, IEnumerable<ICallHandl
return _pipelines[key];
}

if (method.GetBaseDefinition() == method)
var baseMethodDefinition = BaseMethodDefinitions.GetOrAdd(key, k => method.GetBaseDefinition());

if (baseMethodDefinition == method)
{
_pipelines[key] = new HandlerPipeline(handlers);
return _pipelines[key];
}

var basePipeline = CreatePipeline(method.GetBaseDefinition(), handlers);
var basePipeline = CreatePipeline(baseMethodDefinition, handlers);
_pipelines[key] = basePipeline;
return basePipeline;
}
Expand Down