protected override Expression BuildExpression(FilterParameters parameters) { var systemEvent = parameters.GetParameter(typeof(SystemEvent)); var propertyName = ExtendedProperties.GetExtendedProperty("property"); var propertyExpression = Expression.Property(systemEvent, propertyName); return(expressionBuilder.Invoke( ConvertPropertyValueIfRequired(propertyExpression), GetConvertedValue(propertyExpression.Type) )); }
protected Expression GetConvertedValue(Type targetType) { var value = ExtendedProperties.GetExtendedProperty("value") ?? String.Empty; if (targetType.IsEnum) { return(Expression.Constant(((IConvertible)Enum.Parse(targetType, value, true)).ToType(targetType.GetEnumUnderlyingType(), CultureInfo.InvariantCulture))); } return(typeof(IConvertible).IsAssignableFrom(targetType) ? Expression.Constant(((IConvertible)value).ToType(targetType, CultureInfo.InvariantCulture)) : Expression.Convert(Expression.Constant(value), targetType) as Expression); }