public PrimitiveElement(object value, string name = null) { if (value == null) { throw new ArgumentNullException(nameof(value)); } Value = Primitives.ConvertToPrimitiveValue(value); InstanceType = Primitives.GetPrimitiveTypeName(value.GetType()); Name = name ?? "@primitivevalue@"; }
public ConstantExpression(object value, ISourcePositionInfo location = null) : base(TypeInfo.Any, location) { if (value == null) { Error.ArgumentNull("value"); } Value = Primitives.ConvertToPrimitiveValue(value); if (Value is bool) { ExpressionType = TypeInfo.Boolean; } else if (Value is string) { ExpressionType = TypeInfo.String; } else if (Value is Int64) { ExpressionType = TypeInfo.Integer; } else if (Value is Decimal) { ExpressionType = TypeInfo.Decimal; } else if (Value is PartialDateTime) { ExpressionType = TypeInfo.DateTime; } else if (Value is PartialTime) { ExpressionType = TypeInfo.Time; } else { throw Error.InvalidOperation("Internal logic error: encountered unmappable Value of type " + Value.GetType().Name); } }