unitycontainer/experimental

Implement IAddPolicies interface

Opened this issue · 0 comments

ENikS commented

Description

InjectionMember class implements AddPolicies methods called during registration. Default implementation does nothing, but derived types are allowed to override it to inject required policies into registration.

Problem

  • This method is called even if nothing to register
  • The injection member is kept in memory even when policies are added to the registration.
  • Both of these, when not used add unnecessary overhead.

Solution

  • To optimize performance interface IAddPolicies should be implemented.

  • Injection Members requiring active registration must implement this interface.

  • Method AddPolicies(Type typeToCreate, IPolicyList policies) will be removed from InjectionMember as redundant.

Interface

    public interface IAddPolicies
    {
        public abstract void AddPolicies(Type type, string? name, ref IPolicySet policies)
    }

Impact

Custom Injection Members will require refactoring