Skip to content

Commit 782082f

Browse files
committed
Making extension methods obsolete
1 parent 3c9dd90 commit 782082f

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

src/Container/IContainerContext.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ public interface IContainerContext
1717
IUnityContainer Container { get; }
1818

1919
/// <summary>
20-
/// Retrieves registration for requested named type
21-
/// </summary>
22-
/// <param name="type">Registration type</param>
23-
/// <param name="name">Registration name</param>
24-
/// <param name="create">Instruncts container if it should create registration if not found</param>
25-
/// <returns>Registration for requested named type or null if named type is not registered and <see cref="create"/> is false</returns>
26-
IRegistration Registration(Type type, string name, bool create = false);
27-
28-
/// <summary>
2920
/// Generic method to retrieve policy for registered named type.
3021
/// </summary>
3122
/// <typeparam name="TPolicy">Type of the policy to retrieve</typeparam>

src/Registration/IContainerRegistration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ namespace Unity.Registration
88
/// <summary>
99
/// Information about the types registered in a container.
1010
/// </summary>
11-
public interface IContainerRegistration : IRegistration
11+
public interface IContainerRegistration : INamedType
1212
{
1313
/// <summary>
1414
/// The type that this registration is mapped to. If no type mapping was done, the
15-
/// <see cref="IRegistration.RegisteredType"/> property and this one will have the same value.
15+
/// <see cref="INamedType.RegisteredType"/> property and this one will have the same value.
1616
/// </summary>
1717
Type MappedToType { get; }
1818

src/Registration/INamedType.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Unity.Registration
6+
{
7+
/// <summary>
8+
/// Basic information about registered type
9+
/// </summary>
10+
public interface INamedType
11+
{
12+
/// <summary>
13+
/// Type of the registration.
14+
/// </summary>
15+
Type RegisteredType { get; }
16+
17+
/// <summary>
18+
/// Name the registered type. Null for default registration.
19+
/// </summary>
20+
string Name { get; }
21+
}
22+
}

src/Registration/IRegistration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Unity.Registration
55
/// <summary>
66
/// Basic information about registered type
77
/// </summary>
8-
public interface IRegistration
8+
public interface I_Registration
99
{
1010
/// <summary>
1111
/// Type of the registration.

src/Utility/PolicyListExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static class PolicyListExtensions
2121
/// <param name="policies"></param>
2222
/// <param name="policyInterface">The type of policy to remove.</param>
2323
/// <param name="buildKey">The key the policy applies.</param>
24+
[Obsolete("Use IPolicyList.Clear(...)")]
2425
public static void Clear(this IPolicyList policies, Type policyInterface, object buildKey)
2526
{
2627
var key = ParseBuildKey(buildKey);
@@ -33,6 +34,7 @@ public static void Clear(this IPolicyList policies, Type policyInterface, object
3334
/// <typeparam name="TPolicyInterface">The type the policy was registered as.</typeparam>
3435
/// <param name="policies"><see cref="IPolicyList"/> to remove the policy from.</param>
3536
/// <param name="buildKey">The key the policy applies.</param>
37+
[Obsolete("Use IPolicyList.Clear(...)")]
3638
public static void Clear<TPolicyInterface>(this IPolicyList policies, object buildKey)
3739
where TPolicyInterface : IBuilderPolicy
3840
{
@@ -45,6 +47,7 @@ public static void Clear<TPolicyInterface>(this IPolicyList policies, object bui
4547
/// </summary>
4648
/// <typeparam name="TPolicyInterface">The type the policy was registered as.</typeparam>
4749
/// <param name="policies"><see cref="IPolicyList"/> to remove the policy from.</param>
50+
[Obsolete("Use IPolicyList.Clear(null, null, ...)")]
4851
public static void ClearDefault<TPolicyInterface>(this IPolicyList policies)
4952
where TPolicyInterface : IBuilderPolicy
5053
{
@@ -57,6 +60,7 @@ public static void ClearDefault<TPolicyInterface>(this IPolicyList policies)
5760
/// </summary>
5861
/// <param name="policies"></param>
5962
/// <param name="policyInterface">The type the policy was registered as.</param>
63+
[Obsolete("Use IPolicyList.Clear(null, null, ...)")]
6064
public static void ClearDefault(this IPolicyList policies, Type policyInterface)
6165
{
6266
(policies ?? throw new ArgumentNullException(nameof(policies))).Clear(null, null, policyInterface);
@@ -74,6 +78,7 @@ public static void ClearDefault(this IPolicyList policies, Type policyInterface)
7478
/// <param name="policyInterface">The <see cref="Type"/> of the policy.</param>
7579
/// <param name="policy">The policy to be registered.</param>
7680
/// <param name="buildKey">The key the policy applies.</param>
81+
[Obsolete("Use IPolicyList.Set(...)")]
7782
public static void Set(this IPolicyList policies, Type policyInterface, IBuilderPolicy policy, object buildKey = null)
7883
{
7984
var key = ParseBuildKey(buildKey);
@@ -133,6 +138,7 @@ public static void SetDefault<TPolicyInterface>(this IPolicyList policies, TPoli
133138
/// <param name="policyInterface">The interface the policy is registered under.</param>
134139
/// <param name="buildKey">The key the policy applies.</param>
135140
/// <returns>The policy in the list, if present; returns null otherwise.</returns>
141+
[Obsolete("Use IPolicyList.Get(...)")]
136142
public static IBuilderPolicy Get(this IPolicyList policies, Type policyInterface, object buildKey)
137143
{
138144
return (policies ?? throw new ArgumentNullException(nameof(policies))).GetOrDefault(policyInterface, buildKey, out IPolicyList _);

0 commit comments

Comments
 (0)