OpenGenericRule
using Stashbox.Resolution;
using System;
namespace Stashbox.Registration.SelectionRules
{
internal class OpenGenericRule : IRegistrationSelectionRule
{
public bool IsValidForCurrentRequest(TypeInformation typeInformation, ServiceRegistration registration, ResolutionContext resolutionContext)
{
if (typeInformation.Type.IsClosedGenericType())
return typeInformation.Type.SatisfiesGenericConstraintsOf(registration.ImplementationType);
return true;
}
public bool ShouldIncrementWeight(TypeInformation typeInformation, ServiceRegistration registration, ResolutionContext resolutionContext)
{
return false;
}
}
}