@@ -70,7 +70,7 @@ public override void PreBuildUp(IBuilderContext context)
7070 var enumerable = interceptionBehaviors as IInterceptionBehavior [ ] ?? interceptionBehaviors . ToArray ( ) ;
7171 context . Policies . Set (
7272 new EffectiveInterceptionBehaviorsPolicy { Behaviors = enumerable } ,
73- context . BuildKey ) ;
73+ context . OriginalBuildKey ) ;
7474
7575 Type [ ] allAdditionalInterfaces =
7676 Intercept . GetAllAdditionalInterfaces ( enumerable , additionalInterfaces ) ;
@@ -98,7 +98,7 @@ public override void PostBuildUp(IBuilderContext context)
9898 }
9999
100100 EffectiveInterceptionBehaviorsPolicy effectiveInterceptionBehaviorsPolicy =
101- context . Policies . GetNoDefault < EffectiveInterceptionBehaviorsPolicy > ( context . BuildKey ) ;
101+ context . Policies . GetNoDefault < EffectiveInterceptionBehaviorsPolicy > ( context . OriginalBuildKey ) ;
102102 if ( effectiveInterceptionBehaviorsPolicy == null )
103103 {
104104 return ;
@@ -113,8 +113,8 @@ public override void PostBuildUp(IBuilderContext context)
113113 private static TPolicy FindInterceptionPolicy < TPolicy > ( IBuilderContext context )
114114 where TPolicy : class , IBuilderPolicy
115115 {
116- return context . Policies . Get < TPolicy > ( context . BuildKey ) ??
117- context . Policies . Get < TPolicy > ( context . BuildKey . Type ) ;
116+ return context . Policies . Get < TPolicy > ( context . OriginalBuildKey ) ??
117+ context . Policies . Get < TPolicy > ( context . OriginalBuildKey . Type ) ;
118118 }
119119
120120 private class EffectiveInterceptionBehaviorsPolicy : IBuilderPolicy
@@ -167,25 +167,23 @@ private static SelectedConstructor FindNewConstructor(SelectedConstructor origin
167167
168168 public static void SetPolicyForInterceptingType ( IBuilderContext context , Type interceptingType )
169169 {
170- IPolicyList selectorPolicyDestination ;
171- var currentSelectorPolicy = context . Policies . Get < IConstructorSelectorPolicy > ( context . BuildKey , out selectorPolicyDestination ) ;
172- var currentDerivedTypeSelectorPolicy = currentSelectorPolicy as DerivedTypeConstructorSelectorPolicy ;
170+ var currentSelectorPolicy = context . Policies . Get < IConstructorSelectorPolicy > ( context . OriginalBuildKey , out var selectorPolicyDestination ) ;
173171
174- if ( currentDerivedTypeSelectorPolicy == null )
172+ if ( ! ( currentSelectorPolicy is DerivedTypeConstructorSelectorPolicy currentDerivedTypeSelectorPolicy ) )
175173 {
176174 selectorPolicyDestination . Set < IConstructorSelectorPolicy > (
177175 new DerivedTypeConstructorSelectorPolicy (
178176 interceptingType ,
179177 currentSelectorPolicy ) ,
180- context . BuildKey ) ;
178+ context . OriginalBuildKey ) ;
181179 }
182180 else if ( currentDerivedTypeSelectorPolicy . _interceptingType != interceptingType )
183181 {
184182 selectorPolicyDestination . Set < IConstructorSelectorPolicy > (
185183 new DerivedTypeConstructorSelectorPolicy (
186184 interceptingType ,
187185 currentDerivedTypeSelectorPolicy . _originalConstructorSelectorPolicy ) ,
188- context . BuildKey ) ;
186+ context . OriginalBuildKey ) ;
189187 }
190188 }
191189 }
0 commit comments