Skip to content

Commit fb3b064

Browse files
authored
Merge pull request #8 from ENikS/master
Updating references to Abstractions.3.0.0 and Container.5.5.0
2 parents add4d02 + 1f9dbd5 commit fb3b064

4 files changed

Lines changed: 25 additions & 29 deletions

File tree

package.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<PropertyGroup>
9-
<UnityAbstractionsVersion>2.*</UnityAbstractionsVersion>
9+
<UnityAbstractionsVersion>3.*</UnityAbstractionsVersion>
1010
<UnityContainerVersion>5.*</UnityContainerVersion>
1111
</PropertyGroup>
1212

src/ContainerIntegration/ObjectBuilder/InstanceInterceptionStrategy.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public class InstanceInterceptionStrategy : BuilderStrategy
2323
/// phase and executes in reverse order from the PreBuildUp calls.
2424
/// </summary>
2525
/// <param name="context">Context of the build operation.</param>
26-
public override void PostBuildUp(IBuilderContext context)
26+
/// <param name="pre"></param>
27+
public override void PostBuildUp(IBuilderContext context, object pre = null)
2728
{
2829
// If it's already been intercepted, don't do it again.
2930
if ((context ?? throw new ArgumentNullException(nameof(context))).Existing is IInterceptingProxy)

src/ContainerIntegration/ObjectBuilder/TypeInterceptionStrategy.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ public class TypeInterceptionStrategy : BuilderStrategy
2929
/// <remarks>In this class, PreBuildUp is responsible for figuring out if the
3030
/// class is proxyable, and if so, replacing it with a proxy class.</remarks>
3131
/// <param name="context">Context of the build operation.</param>
32-
public override void PreBuildUp(IBuilderContext context)
32+
public override object PreBuildUp(IBuilderContext context)
3333
{
3434
if ((context ?? throw new ArgumentNullException(nameof(context))).Existing != null)
3535
{
36-
return;
36+
return null;
3737
}
3838

3939
Type typeToBuild = context.BuildKey.Type;
4040

4141
var interceptionPolicy = FindInterceptionPolicy<ITypeInterceptionPolicy>(context);
4242
if (interceptionPolicy == null)
4343
{
44-
return;
44+
return null;
4545
}
4646

4747
var interceptor = interceptionPolicy.GetInterceptor(context);
4848
if (!interceptor.CanIntercept(typeToBuild))
4949
{
50-
return;
50+
return null;
5151
}
5252

5353
var interceptionBehaviorsPolicy = FindInterceptionPolicy<IInterceptionBehaviorsPolicy>(context);
@@ -80,6 +80,8 @@ public override void PreBuildUp(IBuilderContext context)
8080
interceptor.CreateProxyType(typeToBuild, allAdditionalInterfaces);
8181

8282
DerivedTypeConstructorSelectorPolicy.SetPolicyForInterceptingType(context, interceptingType);
83+
84+
return null;
8385
}
8486

8587
/// <summary>
@@ -90,7 +92,8 @@ public override void PreBuildUp(IBuilderContext context)
9092
/// <remarks>In this class, PostBuildUp checks to see if the object was proxyable,
9193
/// and if it was, wires up the handlers.</remarks>
9294
/// <param name="context">Context of the build operation.</param>
93-
public override void PostBuildUp(IBuilderContext context)
95+
/// <param name="pre"></param>
96+
public override void PostBuildUp(IBuilderContext context, object pre = null)
9497
{
9598
IInterceptingProxy proxy =
9699
(context ?? throw new ArgumentNullException(nameof(context))).Existing as IInterceptingProxy;
@@ -163,7 +166,7 @@ private static SelectedConstructor FindNewConstructor(SelectedConstructor origin
163166

164167
SelectedConstructor newConstructor = new SelectedConstructor(newConstructorInfo);
165168

166-
foreach (IDependencyResolverPolicy resolver in originalConstructor.GetParameterResolvers())
169+
foreach (IResolverPolicy resolver in originalConstructor.GetParameterResolvers())
167170
{
168171
newConstructor.AddParameterResolver(resolver);
169172
}

tests/TestSupport/MockBuilderContext.cs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,14 @@ public object Existing
8989

9090
public IUnityContainer Container { get; set; }
9191

92+
public IBuilderContext ParentContext => throw new NotImplementedException();
93+
9294
public void AddResolverOverrides(IEnumerable<ResolverOverride> newOverrides)
9395
{
9496
resolverOverrides.AddRange(newOverrides);
9597
}
9698

97-
public IDependencyResolverPolicy GetOverriddenResolver(Type dependencyType)
99+
public IResolverPolicy GetOverriddenResolver(Type dependencyType)
98100
{
99101
return resolverOverrides.GetResolver(this, dependencyType);
100102
}
@@ -127,17 +129,15 @@ public object NewBuildUp(INamedType newBuildKey)
127129
return clone.Strategies.ExecuteBuildUp(clone);
128130
}
129131

130-
/// <summary>
131-
/// A convenience method to do a new buildup operation on an existing context. This
132-
/// overload allows you to specify extra policies which will be in effect for the duration
133-
/// of the build.
134-
/// </summary>
135-
/// <param name="newBuildKey">Key defining what to build up.</param>
136-
/// <param name="childCustomizationBlock">A delegate that takes a <see cref="IBuilderContext"/>. This
137-
/// is invoked with the new child context before the build up process starts. This gives callers
138-
/// the opportunity to customize the context for the build process.</param>
139-
/// <returns>Created object.</returns>
140-
public object NewBuildUp(INamedType newBuildKey, Action<IBuilderContext> childCustomizationBlock)
132+
public object ExecuteBuildUp(INamedType buildKey, object existing)
133+
{
134+
this.BuildKey = buildKey;
135+
this.Existing = existing;
136+
137+
return Strategies.ExecuteBuildUp(this);
138+
}
139+
140+
public object NewBuildUp(Type type, string name, Action<IBuilderContext> childCustomizationBlock = null)
141141
{
142142
var newContext = new MockBuilderContext
143143
{
@@ -146,7 +146,7 @@ public object NewBuildUp(INamedType newBuildKey, Action<IBuilderContext> childCu
146146
policies = new PolicyList(persistentPolicies),
147147
lifetime = lifetime,
148148
originalBuildKey = buildKey,
149-
buildKey = newBuildKey,
149+
buildKey = new NamedTypeBuildKey(type, name),
150150
existing = null
151151
};
152152
newContext.resolverOverrides.Add(resolverOverrides);
@@ -155,13 +155,5 @@ public object NewBuildUp(INamedType newBuildKey, Action<IBuilderContext> childCu
155155

156156
return strategies.ExecuteBuildUp(newContext);
157157
}
158-
159-
public object ExecuteBuildUp(INamedType buildKey, object existing)
160-
{
161-
this.BuildKey = buildKey;
162-
this.Existing = existing;
163-
164-
return Strategies.ExecuteBuildUp(this);
165-
}
166158
}
167159
}

0 commit comments

Comments
 (0)