DefaultValueResolver
using System.Linq.Expressions;
using System.Reflection;
namespace Stashbox.Resolution.Resolvers
{
internal class DefaultValueResolver : IResolver
{
public Expression GetExpression(IResolutionStrategy resolutionStrategy, TypeInformation typeInfo, ResolutionContext resolutionContext)
{
return typeInfo.Type.AsDefault();
}
public bool CanUseForResolution(TypeInformation typeInfo, ResolutionContext resolutionContext)
{
if (resolutionContext.CurrentContainerContext.ContainerConfiguration.DefaultValueInjectionEnabled) {
if (!typeInfo.Type.GetTypeInfo().IsValueType)
return typeInfo.Type == typeof(string);
return true;
}
return false;
}
}
}