dotnet-dynamic-linq/PoweredSoft.DynamicLinq/Parser/ParserExtensions.cs

36 lines
974 B
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace PoweredSoft.DynamicLinq.Parser
{
public static class ParserExtensions
{
public static ExpressionParserPiece FirstEnumerableParent(this ExpressionParserPiece piece)
{
var result = ExpressionParser.GetFirstEnumerableParent(piece);
return result;
}
2018-04-10 20:00:40 -04:00
public static Type GroupEnumerableType(this ExpressionParserPieceGroup group)
{
return group.Pieces.Last().EnumerableType;
}
2018-04-05 20:40:33 -04:00
public static Type ResolveNullHandlingType(this List<ExpressionParserPieceGroup> groups)
{
if (groups.Count() == 1)
{
2018-04-10 20:29:43 -04:00
return groups.First().Pieces.Last().Type;
2018-04-05 20:40:33 -04:00
}
var type = groups.Last().Pieces.Last().Type;
return typeof(IEnumerable<>).MakeGenericType(type);
}
}
}