diff --git a/src/Policy/IDependencyResolverTrackerPolicy.cs b/src/Policy/IDependencyResolverTrackerPolicy.cs deleted file mode 100644 index 9094f3d4..00000000 --- a/src/Policy/IDependencyResolverTrackerPolicy.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. - -using Unity.Builder; - -namespace Unity.Policy -{ - /// - /// A builder policy that lets you keep track of the current - /// resolvers and will remove them from the given policy set. - /// - public interface IDependencyResolverTrackerPolicy : IBuilderPolicy - { - /// - /// Add a new resolver to track by key. - /// - /// Key that was used to add the resolver to the policy set. - void AddResolverKey(object key); - - /// - /// Remove the currently tracked resolvers from the given policy list. - /// - /// Policy list to remove the resolvers from. - void RemoveResolvers(IPolicyList policies); - } -} diff --git a/src/ResolverPolicy/DependencyResolverTrackerPolicy.cs b/src/ResolverPolicy/DependencyResolverTrackerPolicy.cs deleted file mode 100644 index a851f597..00000000 --- a/src/ResolverPolicy/DependencyResolverTrackerPolicy.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. - -using System.Collections.Generic; -using Unity.Policy; - -namespace Unity.ResolverPolicy -{ - /// - /// Implementation of . - /// - public class DependencyResolverTrackerPolicy : IDependencyResolverTrackerPolicy - { - private readonly List _keys = new List(); - - /// - /// Add a new resolver to track by key. - /// - /// Key that was used to add the resolver to the policy set. - public void AddResolverKey(object key) - { - lock (_keys) - { - _keys.Add(key); - } - } - - /// - /// Remove the currently tracked resolvers from the given policy list. - /// - /// Policy list to remove the resolvers from. - public void RemoveResolvers(IPolicyList policies) - { - var allKeys = new List(); - lock (_keys) - { - allKeys.AddRange(_keys); - _keys.Clear(); - } - - foreach (object key in allKeys) - { - policies.Clear(key); - } - } - - // Helper methods for adding and removing the tracker policy. - - /// - /// GetOrDefault an instance that implements , - /// either the current one in the policy set or creating a new one if it doesn't - /// exist. - /// - /// Policy list to look up from. - /// Build key to track. - /// The resolver tracker. - public static IDependencyResolverTrackerPolicy GetTracker(IPolicyList policies, object buildKey) - { - IDependencyResolverTrackerPolicy tracker = - policies.Get(buildKey); - if (tracker == null) - { - tracker = new DependencyResolverTrackerPolicy(); - policies.Set(tracker, buildKey); - } - return tracker; - } - - /// - /// Add a key to be tracked to the current tracker. - /// - /// Policy list containing the resolvers and trackers. - /// Build key for the resolvers being tracked. - /// Key for the resolver. - public static void TrackKey(IPolicyList policies, object buildKey, object resolverKey) - { - IDependencyResolverTrackerPolicy tracker = GetTracker(policies, buildKey); - tracker.AddResolverKey(resolverKey); - } - - /// - /// Remove the resolvers for the given build key. - /// - /// Policy list containing the build key. - /// Build key. - public static void RemoveResolvers(IPolicyList policies, object buildKey) - { - IDependencyResolverTrackerPolicy tracker = policies.Get(buildKey); - tracker?.RemoveResolvers(policies); - } - } -}