/// <summary>
        /// Converts a constant from one quotation data type to another.
        /// </summary>
        /// <param name="originalValue">Original value to convert.</param>
        /// <param name="oldDataType">Old data type.</param>
        /// <param name="newDataType">New data type.</param>
        /// <returns>Converted constant.</returns>
        protected virtual object ConvertConstantQuotation(object originalValue, QuotationDataType oldDataType, QuotationDataType newDataType)
        {
            var oldExpression = originalValue as LambdaExpressionSlim ?? oldDataType.GetExpression(originalValue).ToExpressionSlim();
            var newExpression = Parent.Apply(oldExpression);

            return(newDataType.CreateInstance(newExpression));
        }
 protected override bool EqualsQuotation(object expected, object actual, QuotationDataType expectedDataType, QuotationDataType actualDataType)
 {
     return(EqualsExpressionCore(expected, actual));
 }
 /// <summary>
 /// Checks if a constant can be converted from one quotation data type to another.
 /// </summary>
 /// <param name="newValue">Converted value.</param>
 /// <param name="oldDataType">Old data type.</param>
 protected virtual void CheckConstantQuotation(Object newValue, QuotationDataType oldDataType)
 {
 }
예제 #4
0
 protected override bool EqualsQuotation(object expected, object actual, QuotationDataType expectedDataType, QuotationDataType actualDataType)
 {
     return(ExpressionComparator.Equals((Expression)expected, (Expression)actual));
 }
 /// <summary>
 /// QuotationDataType的格式化方法
 /// </summary>
 /// <param name="qdt"></param>
 /// <returns></returns>
 public static string ToFormatString(this QuotationDataType qdt)
 {
     return(((int)qdt).ToString("00"));
 }
예제 #6
0
 protected override Type MakeQuotation(QuotationDataType type, Type functionType)
 {
     return(typeof(Expression <>).MakeGenericType(functionType));
 }
        protected override LambdaExpression MakeQuotation(QuotationDataType type, LambdaExpression functionType)
        {
            Debug.Assert(functionType == null);

            return(MakeExpressionCore(type.UnderlyingType));
        }
 protected override LambdaExpression VisitQuotation(QuotationDataType type)
 {
     // No need to recurse into function type, this will be serialized as an expression anyway.
     return(MakeQuotation(type, functionType: null));
 }