예제 #1
0
 /// <summary>
 /// Creates a <see cref="ConstantExpression"/> that has the <see cref="P:ConstantExpression.Value"/>
 /// and <see cref="P:ConstantExpression.Type"/> properties set to the specified values. .
 /// </summary>
 /// <param name="value">An <see cref="System.Object"/> to set the <see cref="P:ConstantExpression.Value"/> property equal to.</param>
 /// <param name="type">A <see cref="System.Type"/> to set the <see cref="P:Expression.Type"/> property equal to.</param>
 /// <returns>
 /// A <see cref="ConstantExpression"/> that has the <see cref="P:Expression.NodeType"/> property equal to
 /// <see cref="F:ExpressionType.Constant"/> and the <see cref="P:ConstantExpression.Value"/> and
 /// <see cref="P:Expression.Type"/> properties set to the specified values.
 /// </returns>
 public static ConstantExpression Constant(object value, Type type)
 {
     ContractUtils.RequiresNotNull(type, "type");
     if (value == null && type.IsValueType && !TypeUtils.IsNullableType(type))
     {
         throw Error.ArgumentTypesMustMatch();
     }
     if (value != null && !type.IsAssignableFrom(value.GetType()))
     {
         throw Error.ArgumentTypesMustMatch();
     }
     return(ConstantExpression.Make(value, type));
 }
예제 #2
0
 public static ConstantExpression Constant(object value, XzaarType type)
 {
     return(ConstantExpression.Make(value, type));
 }
예제 #3
0
 public static ConstantExpression Constant(object value)
 {
     return(ConstantExpression.Make(value, value == null ? (XzaarType)typeof(object) : (XzaarType)value.GetType()));
 }