RegistrationConfiguration
Represents the collected configuration options of a registration.
using System;
namespace Stashbox.Registration.Fluent
{
public class RegistrationConfiguration
{
public Type ServiceType { get; }
public Type ImplementationType { get; set; }
internal RegistrationContext Context { get; }
internal RegistrationConfiguration(Type serviceType, Type implementationType)
{
ServiceType = serviceType;
ImplementationType = implementationType;
Context = new RegistrationContext();
}
internal bool TypeMapIsValid(out string error)
{
error = null;
if ((object)Context.ContainerFactory != null || (object)Context.SingleFactory != null)
return true;
if (!ImplementationType.IsResolvableType()) {
error = $"""{ImplementationType}""";
return false;
}
if (ImplementationType.Implements(ServiceType))
return true;
error = $"""{ImplementationType}""{ServiceType}""";
return false;
}
internal bool ImplementationIsResolvable(out string error)
{
error = null;
if ((object)Context.ContainerFactory != null || (object)Context.SingleFactory != null)
return true;
if (ImplementationType.IsResolvableType())
return true;
error = $"""{ImplementationType}""";
return false;
}
}
}