EnumerableResolver
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
namespace Stashbox.Resolution.Resolvers
{
internal class EnumerableResolver : IResolver
{
public Expression GetExpression(IResolutionStrategy resolutionStrategy, TypeInformation typeInfo, ResolutionContext resolutionContext)
{
TypeInformation typeInformation = typeInfo.CloneForType(typeInfo.Type.GetEnumerableType());
IEnumerable<Expression> enumerable = resolutionStrategy.BuildExpressionsForEnumerableRequest(resolutionContext, typeInformation);
if (enumerable != null)
return typeInformation.Type.InitNewArray(enumerable);
return typeInformation.Type.InitNewArray(Array.Empty<Expression>());
}
public bool CanUseForResolution(TypeInformation typeInfo, ResolutionContext resolutionContext)
{
return typeInfo.Type.GetEnumerableType() != (Type)null;
}
}
}