NameRule
using Stashbox.Entity;
using Stashbox.Resolution;
namespace Stashbox.Registration.SelectionRules
{
internal class NameRule : IRegistrationSelectionRule
{
public bool IsValidForCurrentRequest(TypeInformation typeInformation, IServiceRegistration registration, ResolutionContext resolutionContext)
{
if (typeInformation.DependencyName != null && !registration.RegistrationName.Equals(typeInformation.DependencyName) && !registration.IsResolvableByUnnamedRequest)
return false;
if (typeInformation.DependencyName == null)
return registration.IsResolvableByUnnamedRequest;
return true;
}
public bool ShouldIncrementWeight(TypeInformation typeInformation, IServiceRegistration registration, ResolutionContext resolutionContext)
{
if (typeInformation.DependencyName != null)
return registration.RegistrationName.Equals(typeInformation.DependencyName);
return false;
}
}
}