Skip to content

Commit 7a99a90

Browse files
committed
Deprecated Microsoft.Practices.Unity.InterceptionExtension
1 parent 95fbc3f commit 7a99a90

File tree

170 files changed

+1214
-1422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+1214
-1422
lines changed

src/ContainerIntegration/AdditionalInterface.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22

33
using System;
44
using System.Globalization;
5-
using Microsoft.Practices.ObjectBuilder2;
5+
using Unity.Interception.ContainerIntegration.ObjectBuilder;
66
using Unity.Interception.Properties;
7-
using Microsoft.Practices.Unity.Utility;
8-
using Unity;
97
using Unity.Policy;
108

11-
namespace Microsoft.Practices.Unity.InterceptionExtension
9+
namespace Unity.Interception.ContainerIntegration
1210
{
1311
/// <summary>
1412
/// Stores information about a single <see cref="Type"/> to be an additional interface for an intercepted object and
1513
/// configures a container accordingly.
1614
/// </summary>
1715
public class AdditionalInterface : InterceptionMember
1816
{
19-
private readonly Type additionalInterface;
17+
private readonly Type _additionalInterface;
2018

2119
/// <summary>
2220
/// Initializes a new instance of the <see cref="AdditionalInterface"/> with a
@@ -27,22 +25,19 @@ public class AdditionalInterface : InterceptionMember
2725
/// <see langword="null"/>.</exception>
2826
/// <exception cref="ArgumentException">when <paramref name="additionalInterface"/> is not an interface.
2927
/// </exception>
30-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods",
31-
Justification = "Validation done by Guard class")]
3228
public AdditionalInterface(Type additionalInterface)
3329
{
34-
Guard.ArgumentNotNull(additionalInterface, "additionalInterface");
35-
if (!additionalInterface.IsInterface)
30+
if (!(additionalInterface ?? throw new ArgumentNullException(nameof(additionalInterface))).IsInterface)
3631
{
3732
throw new ArgumentException(
3833
string.Format(
3934
CultureInfo.CurrentCulture,
4035
Resources.ExceptionTypeIsNotInterface,
4136
additionalInterface.Name),
42-
"additionalInterface");
37+
nameof(additionalInterface));
4338
}
4439

45-
this.additionalInterface = additionalInterface;
40+
_additionalInterface = additionalInterface;
4641
}
4742

4843
/// <summary>
@@ -57,7 +52,7 @@ public override void AddPolicies(Type serviceType, Type implementationType, stri
5752
{
5853
AdditionalInterfacesPolicy policy =
5954
AdditionalInterfacesPolicy.GetOrCreate(policies, implementationType, name);
60-
policy.AddAdditionalInterface(this.additionalInterface);
55+
policy.AddAdditionalInterface(_additionalInterface);
6156
}
6257
}
6358

src/ContainerIntegration/DefaultInterceptionBehavior.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
22

33
using System;
4-
using Microsoft.Practices.ObjectBuilder2;
5-
using Unity;
4+
using Unity.Interception.ContainerIntegration.ObjectBuilder;
5+
using Unity.Interception.InterceptionBehaviors;
66
using Unity.Policy;
77

8-
namespace Microsoft.Practices.Unity.InterceptionExtension
8+
namespace Unity.Interception.ContainerIntegration
99
{
1010
/// <summary>
1111
/// An injection member that lets you specify behaviors that should

src/ContainerIntegration/DefaultInterceptor.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
22

33
using System;
4-
using Microsoft.Practices.ObjectBuilder2;
5-
using Microsoft.Practices.Unity.Utility;
6-
using Unity;
74
using Unity.Builder;
5+
using Unity.Interception.ContainerIntegration.ObjectBuilder;
6+
using Unity.Interception.Interceptors;
7+
using Unity.Interception.Interceptors.InstanceInterceptors;
8+
using Unity.Interception.Interceptors.TypeInterceptors;
9+
using Unity.Interception.Utilities;
810
using Unity.Policy;
911
using Unity.Registration;
1012

11-
namespace Microsoft.Practices.Unity.InterceptionExtension
13+
namespace Unity.Interception.ContainerIntegration
1214
{
1315
/// <summary>
1416
/// A <see cref="InjectionMember"/> that can be passed to the
@@ -19,8 +21,8 @@ namespace Microsoft.Practices.Unity.InterceptionExtension
1921
/// </summary>
2022
public class DefaultInterceptor : InjectionMember
2123
{
22-
private readonly IInterceptor interceptor;
23-
private readonly NamedTypeBuildKey interceptorKey;
24+
private readonly IInterceptor _interceptor;
25+
private readonly NamedTypeBuildKey _interceptorKey;
2426

2527
/// <summary>
2628
/// Construct a new <see cref="DefaultInterceptor"/> instance that,
@@ -30,9 +32,7 @@ public class DefaultInterceptor : InjectionMember
3032
/// <param name="interceptor">Interceptor to use.</param>
3133
public DefaultInterceptor(IInterceptor interceptor)
3234
{
33-
Guard.ArgumentNotNull(interceptor, "intereptor");
34-
35-
this.interceptor = interceptor;
35+
_interceptor = interceptor ?? throw new ArgumentNullException(nameof(interceptor));
3636
}
3737

3838
/// <summary>
@@ -47,7 +47,7 @@ public DefaultInterceptor(Type interceptorType, string name)
4747
Guard.ArgumentNotNull(interceptorType, "interceptorType");
4848
Guard.TypeIsAssignable(typeof(IInterceptor), interceptorType, "interceptorType");
4949

50-
this.interceptorKey = new NamedTypeBuildKey(interceptorType, name);
50+
_interceptorKey = new NamedTypeBuildKey(interceptorType, name);
5151
}
5252

5353
/// <summary>
@@ -72,58 +72,58 @@ public DefaultInterceptor(Type interceptorType)
7272
/// <param name="policies">Policy list to add policies to.</param>
7373
public override void AddPolicies(Type serviceType, Type implementationType, string name, IPolicyList policies)
7474
{
75-
if (this.IsInstanceInterceptor)
75+
if (IsInstanceInterceptor)
7676
{
77-
this.AddDefaultInstanceInterceptor(implementationType, policies);
77+
AddDefaultInstanceInterceptor(implementationType, policies);
7878
}
7979
else
8080
{
81-
this.AddDefaultTypeInterceptor(implementationType, policies);
81+
AddDefaultTypeInterceptor(implementationType, policies);
8282
}
8383
}
8484

8585
private bool IsInstanceInterceptor
8686
{
8787
get
8888
{
89-
if (this.interceptor != null)
89+
if (_interceptor != null)
9090
{
91-
return this.interceptor is IInstanceInterceptor;
91+
return _interceptor is IInstanceInterceptor;
9292
}
93-
return typeof(IInstanceInterceptor).IsAssignableFrom(this.interceptorKey.Type);
93+
return typeof(IInstanceInterceptor).IsAssignableFrom(_interceptorKey.Type);
9494
}
9595
}
9696

9797
private void AddDefaultInstanceInterceptor(Type typeToIntercept, IPolicyList policies)
9898
{
9999
IInstanceInterceptionPolicy policy;
100100

101-
if (this.interceptor != null)
101+
if (_interceptor != null)
102102
{
103-
policy = new FixedInstanceInterceptionPolicy((IInstanceInterceptor)this.interceptor);
103+
policy = new FixedInstanceInterceptionPolicy((IInstanceInterceptor)_interceptor);
104104
}
105105
else
106106
{
107-
policy = new ResolvedInstanceInterceptionPolicy(this.interceptorKey);
107+
policy = new ResolvedInstanceInterceptionPolicy(_interceptorKey);
108108
}
109109

110-
policies.Set<IInstanceInterceptionPolicy>(policy, typeToIntercept);
110+
policies.Set(policy, typeToIntercept);
111111
}
112112

113113
private void AddDefaultTypeInterceptor(Type typeToIntercept, IPolicyList policies)
114114
{
115115
ITypeInterceptionPolicy policy;
116116

117-
if (this.interceptor != null)
117+
if (_interceptor != null)
118118
{
119-
policy = new FixedTypeInterceptionPolicy((ITypeInterceptor)this.interceptor);
119+
policy = new FixedTypeInterceptionPolicy((ITypeInterceptor)_interceptor);
120120
}
121121
else
122122
{
123-
policy = new ResolvedTypeInterceptionPolicy(this.interceptorKey);
123+
policy = new ResolvedTypeInterceptionPolicy(_interceptorKey);
124124
}
125125

126-
policies.Set<ITypeInterceptionPolicy>(policy, typeToIntercept);
126+
policies.Set(policy, typeToIntercept);
127127
}
128128
}
129129

src/ContainerIntegration/Interception.cs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22

33
using System;
44
using System.Globalization;
5-
using Microsoft.Practices.ObjectBuilder2;
6-
using Unity.Interception.Properties;
7-
using Unity;
85
using Unity.Builder;
96
using Unity.Extension;
7+
using Unity.Interception.ContainerIntegration.ObjectBuilder;
8+
using Unity.Interception.Interceptors;
9+
using Unity.Interception.Interceptors.InstanceInterceptors;
10+
using Unity.Interception.Interceptors.TypeInterceptors;
11+
using Unity.Interception.PolicyInjection;
12+
using Unity.Interception.PolicyInjection.Policies;
13+
using Unity.Interception.Properties;
14+
using Unity.Interception.Utilities;
1015
using Unity.Policy;
11-
using Guard = Microsoft.Practices.Unity.Utility.Guard;
1216
using Unity.Strategy;
1317

14-
namespace Microsoft.Practices.Unity.InterceptionExtension
18+
namespace Unity.Interception.ContainerIntegration
1519
{
1620
/// <summary>
1721
/// A Unity container extension that allows you to configure
@@ -36,10 +40,8 @@ protected override void Initialize()
3640
// have taken place.
3741
Context.Strategies.AddNew<InstanceInterceptionStrategy>(UnityBuildStage.Setup);
3842
Context.Strategies.AddNew<TypeInterceptionStrategy>(UnityBuildStage.PreCreation);
39-
Context.Container
40-
.RegisterInstance<InjectionPolicy>(
41-
typeof(AttributeDrivenPolicy).AssemblyQualifiedName,
42-
new AttributeDrivenPolicy());
43+
Context.Container.RegisterInstance<InjectionPolicy>(typeof(AttributeDrivenPolicy).AssemblyQualifiedName,
44+
new AttributeDrivenPolicy());
4345
}
4446

4547
/// <summary>
@@ -76,7 +78,7 @@ public Interception SetInterceptorFor(Type typeToIntercept, string name, ITypeIn
7678
/// <returns>This extension object.</returns>
7779
public Interception SetInterceptorFor(Type typeToIntercept, ITypeInterceptor interceptor)
7880
{
79-
return this.SetInterceptorFor(typeToIntercept, null, interceptor);
81+
return SetInterceptorFor(typeToIntercept, null, interceptor);
8082
}
8183

8284
/// <summary>
@@ -86,10 +88,9 @@ public Interception SetInterceptorFor(Type typeToIntercept, ITypeInterceptor int
8688
/// <param name="name">Name type is registered under.</param>
8789
/// <param name="interceptor">Interceptor object to use.</param>
8890
/// <returns>This extension object.</returns>
89-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "As designed")]
9091
public Interception SetInterceptorFor<T>(string name, ITypeInterceptor interceptor)
9192
{
92-
return this.SetInterceptorFor(typeof(T), name, interceptor);
93+
return SetInterceptorFor(typeof(T), name, interceptor);
9394
}
9495

9596
/// <summary>
@@ -98,10 +99,9 @@ public Interception SetInterceptorFor<T>(string name, ITypeInterceptor intercept
9899
/// <typeparam name="T">Type to intercept</typeparam>
99100
/// <param name="interceptor">Interceptor object to use.</param>
100101
/// <returns>This extension object.</returns>
101-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "As designed")]
102102
public Interception SetInterceptorFor<T>(ITypeInterceptor interceptor)
103103
{
104-
return this.SetInterceptorFor(typeof(T), null, interceptor);
104+
return SetInterceptorFor(typeof(T), null, interceptor);
105105
}
106106

107107
/// <summary>
@@ -158,10 +158,9 @@ public Interception SetDefaultInterceptorFor(Type typeToIntercept, ITypeIntercep
158158
/// <typeparam name="TTypeToIntercept">Type to intercept</typeparam>
159159
/// <param name="interceptor">Interceptor instance.</param>
160160
/// <returns>This extension object.</returns>
161-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "As designed")]
162161
public Interception SetDefaultInterceptorFor<TTypeToIntercept>(ITypeInterceptor interceptor)
163162
{
164-
return this.SetDefaultInterceptorFor(typeof(TTypeToIntercept), interceptor);
163+
return SetDefaultInterceptorFor(typeof(TTypeToIntercept), interceptor);
165164
}
166165

167166
/// <summary>
@@ -172,7 +171,7 @@ public Interception SetDefaultInterceptorFor<TTypeToIntercept>(ITypeInterceptor
172171
/// <returns>This extension object.</returns>
173172
public Interception SetInterceptorFor(Type typeToIntercept, IInstanceInterceptor interceptor)
174173
{
175-
return this.SetInterceptorFor(typeToIntercept, null, interceptor);
174+
return SetInterceptorFor(typeToIntercept, null, interceptor);
176175
}
177176

178177
/// <summary>
@@ -182,10 +181,9 @@ public Interception SetInterceptorFor(Type typeToIntercept, IInstanceInterceptor
182181
/// <param name="name">Name type is registered under.</param>
183182
/// <param name="interceptor">Instance interceptor to use.</param>
184183
/// <returns>This extension object.</returns>
185-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "As designed")]
186184
public Interception SetInterceptorFor<T>(string name, IInstanceInterceptor interceptor)
187185
{
188-
return this.SetInterceptorFor(typeof(T), name, interceptor);
186+
return SetInterceptorFor(typeof(T), name, interceptor);
189187
}
190188

191189
/// <summary>
@@ -194,10 +192,9 @@ public Interception SetInterceptorFor<T>(string name, IInstanceInterceptor inter
194192
/// <typeparam name="T">Type to intercept.</typeparam>
195193
/// <param name="interceptor">Instance interceptor to use.</param>
196194
/// <returns>This extension object.</returns>
197-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "As designed")]
198195
public Interception SetInterceptorFor<T>(IInstanceInterceptor interceptor)
199196
{
200-
return this.SetInterceptorFor(typeof(T), null, interceptor);
197+
return SetInterceptorFor(typeof(T), null, interceptor);
201198
}
202199

203200
/// <summary>
@@ -228,10 +225,9 @@ public Interception SetDefaultInterceptorFor(Type typeToIntercept, IInstanceInte
228225
/// <typeparam name="TTypeToIntercept">Type the interception is being configured for.</typeparam>
229226
/// <param name="interceptor">The interceptor to use by default.</param>
230227
/// <returns>This extension object.</returns>
231-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "As designed")]
232228
public Interception SetDefaultInterceptorFor<TTypeToIntercept>(IInstanceInterceptor interceptor)
233229
{
234-
return this.SetDefaultInterceptorFor(typeof(TTypeToIntercept), interceptor);
230+
return SetDefaultInterceptorFor(typeof(TTypeToIntercept), interceptor);
235231
}
236232

237233
private static void GuardTypeInterceptable(Type typeToIntercept, IInterceptor interceptor)
@@ -243,7 +239,7 @@ private static void GuardTypeInterceptable(Type typeToIntercept, IInterceptor in
243239
CultureInfo.CurrentCulture,
244240
Resources.InterceptionNotSupported,
245241
typeToIntercept.FullName),
246-
"typeToIntercept");
242+
nameof(typeToIntercept));
247243
}
248244
}
249245

src/ContainerIntegration/InterceptionBehavior.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
22

33
using System;
4-
using Microsoft.Practices.ObjectBuilder2;
5-
using Unity;
4+
using Unity.Interception.ContainerIntegration.ObjectBuilder;
5+
using Unity.Interception.InterceptionBehaviors;
66
using Unity.Policy;
77

8-
namespace Microsoft.Practices.Unity.InterceptionExtension
8+
namespace Unity.Interception.ContainerIntegration
99
{
1010
/// <summary>
1111
/// Stores information about a single <see cref="IInterceptionBehavior"/> to be used on an intercepted object and

0 commit comments

Comments
 (0)