MetadataRule
using Stashbox.Resolution;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace Stashbox.Registration.SelectionRules
{
internal class MetadataRule : IRegistrationSelectionRule
{
[System.Runtime.CompilerServices.NullableContext(1)]
public bool IsValidForCurrentRequest(TypeInformation typeInformation, ServiceRegistration registration, ResolutionContext resolutionContext, out bool shouldIncrementWeight)
{
shouldIncrementWeight = false;
if (typeInformation.MetadataType != (Type)null) {
object orDefault = registration.Options.GetOrDefault(RegistrationOption.Metadata);
shouldIncrementWeight = (orDefault != null && typeInformation.MetadataType.IsInstanceOfType(orDefault));
return shouldIncrementWeight;
}
return true;
}
}
}