public static IEnumerable <TSource> GreaterThanOrGreaterThanOrEqual <TSource>( IndexDefinition <TSource> source, BinaryExpression binaryExpression, Func <TSource, bool> predicate, LogicalEnum logicalEnum, bool recalculateIndex = false) { IndexDefinition <TSource> index = (IndexDefinition <TSource>)source; ConstantExpression constantExpression = null; MemberExpression memberExpression = null; object indexDefinition = null; if (binaryExpression.Left.NodeType == ExpressionType.MemberAccess) { memberExpression = (MemberExpression)binaryExpression.Left; var member = memberExpression.Member.Name; indexDefinition = index.Find(member, IndexType.UnequalIndex, recalculateIndex); } else if (binaryExpression.Left.NodeType == ExpressionType.Constant) { constantExpression = (ConstantExpression)binaryExpression.Left; } if (binaryExpression.Right.NodeType == ExpressionType.MemberAccess) { memberExpression = (MemberExpression)binaryExpression.Right; var member = memberExpression.Member.Name; indexDefinition = index.Find(member, IndexType.UnequalIndex, recalculateIndex); } else if (binaryExpression.Right.NodeType == ExpressionType.Constant) { constantExpression = (ConstantExpression)binaryExpression.Right; } if (indexDefinition == null || constantExpression.Type != typeof(int)) { foreach (var innerItem in index.Source.Where(predicate)) { yield return(innerItem); } } else { dynamic indexSource = indexDefinition.GetType().GetProperty("IndexCollection").GetValue(indexDefinition, null); Type typeKey = indexDefinition.GetType().GetGenericArguments()[1]; dynamic items = null; if (logicalEnum == LogicalEnum.GreaterThanOrEqual) { items = indexSource.BiggerThanOrEqualEnumerator(Converting(constantExpression.Value, constantExpression.Type)); } else { items = indexSource.BiggerThanEnumerator(Converting(constantExpression.Value, constantExpression.Type)); } foreach (var item in items) { foreach (var inneritem in item) { yield return(inneritem); } } } }
public static string EnumerationToString(LogicalType serializeAs, object value) { LogicalEnum enumerated = (LogicalEnum)serializeAs; return(enumerated.findName(value)); }
public static object StringToEnumeration(LogicalType type, string value) { LogicalEnum enumeration = (LogicalEnum)type; return(enumeration.findValue(value)); }