public static bool TryConvertToArmExpression(object value, out ArmExpression armExpression) { if (value is null) { armExpression = ArmNullLiteral.Value; return(true); } Type type = value.GetType(); switch (Type.GetTypeCode(type)) { case TypeCode.String: case TypeCode.DateTime: case TypeCode.Char: armExpression = new ArmStringLiteral(value.ToString()); return(true); case TypeCode.Int32: case TypeCode.Int64: case TypeCode.Int16: case TypeCode.UInt32: case TypeCode.UInt64: case TypeCode.UInt16: case TypeCode.Byte: case TypeCode.SByte: armExpression = new ArmIntegerLiteral(Convert.ToInt64(value)); return(true); case TypeCode.Single: case TypeCode.Double: case TypeCode.Decimal: armExpression = new ArmDoubleLiteral(Convert.ToDouble(value)); return(true); case TypeCode.Boolean: armExpression = Convert.ToBoolean(value) ? ArmBooleanLiteral.True : ArmBooleanLiteral.False; return(true); case TypeCode.DBNull: armExpression = ArmNullLiteral.Value; return(true); } if (value is ArmExpression inputArmExpression) { armExpression = inputArmExpression; return(true); } armExpression = null; return(false); }
public override IArmElement Instantiate(IReadOnlyDictionary <IArmString, ArmElement> parameters) { if (Arguments is null) { return(this); } var args = new ArmExpression[Arguments.Count]; for (int i = 0; i < Arguments.Count; i++) { args[i] = (ArmExpression)Arguments[i].Instantiate(parameters); } return(new ArmFunctionCallExpression( (IArmString)Function.Instantiate(parameters), args)); }
public ArmIndexAccessExpression(ArmOperation expression, ArmExpression index) : this() { InnerExpression = expression; Index = index; }