/// <summary> /// Determina se é possível converter a instância corrente no tipo especificado. /// </summary> /// <param name="mathematicsType">O tipo.</param> /// <returns> /// Verdadeiro caso seja possível converter a instância e falso caso contrário. /// </returns> public override bool CanConvertTo(EMathematicsType mathematicsType) { if (mathematicsType == EMathematicsType.BOOLEAN_VALUE || mathematicsType == EMathematicsType.CONDITION) { return(true); } else { return(false); } }
/// <summary> /// Obtém um objecto que resulta da conversão da instância corrente. /// </summary> /// <param name="mathematicsType">O tipo de objecto no qual se pretende converter.</param> /// <returns> /// O objecto convertido. /// </returns> /// <exception cref="ExpressionInterpreterException">Se a conversão não for possível.</exception> public override AMathematicsObject ConvertTo(EMathematicsType mathematicsType) { if (!mathematicsType.Equals(this.mathematicsType)) { throw new ExpressionInterpreterException(string.Format("Can't convert from type {0} to type {1}.", this.mathematicsType, mathematicsType)); } else { return(this); } }
/// <summary> /// Obtém um objecto que resulta da conversão da instância corrente. /// </summary> /// <param name="mathematicsType">O tipo de objecto no qual se pretende converter.</param> /// <returns> /// O objecto convertido. /// </returns> /// <exception cref="ExpressionInterpreterException">Se não for possível converter.</exception> public override AMathematicsObject ConvertTo(EMathematicsType mathematicsType) { if (mathematicsType == EMathematicsType.BOOLEAN_VALUE || mathematicsType == EMathematicsType.CONDITION) { return(this); } else { throw new ExpressionInterpreterException(string.Format("Can't convert from type {0} to type {1}.", this.mathematicsType, mathematicsType)); } }
/// <summary> /// Determina se é possível converter a instância corrente no tipo especificado. /// </summary> /// <param name="mathematicsType">O tipo.</param> /// <returns> /// Verdadeiro caso seja possível converter a instância e falso caso contrário. /// </returns> public override bool CanConvertTo(EMathematicsType mathematicsType) { if (mathematicsType == this.mathematicsType) { return(true); } else { return(false); } }
/// <summary> /// Determina se é possível converter a instância corrente no tipo especificado. /// </summary> /// <param name="mathematicsType">O tipo.</param> /// <returns> /// Verdadeiro caso seja possível converter a instância e falso caso contrário. /// </returns> public override bool CanConvertTo(EMathematicsType mathematicsType) { if (mathematicsType == EMathematicsType.NAME || mathematicsType == EMathematicsType.POLYNOMIAL) { return(true); } else { return(false); } }
/// <summary> /// Obtém um objecto que resulta da conversão da instância corrente. /// </summary> /// <param name="mathematicsType">O tipo de objecto no qual se pretende converter.</param> /// <returns> /// O objecto convertido. /// </returns> /// <exception cref="System.NotImplementedException"></exception> /// <exception cref="ExpressionInterpreterException"></exception> public override AMathematicsObject ConvertTo(EMathematicsType mathematicsType) { if (mathematicsType == EMathematicsType.NAME) { return(this); } else if (mathematicsType == EMathematicsType.POLYNOMIAL) { throw new NotImplementedException(); } else { throw new ExpressionInterpreterException(string.Format("Can't convert from type {0} to type {1}.", this.mathematicsType, mathematicsType)); } }
/// <summary> /// Determina se é possível converter a instância corrente no tipo especificado. /// </summary> /// <param name="mathematicsType">O tipo.</param> /// <returns> /// Verdadeiro caso seja possível converter a instância e falso caso contrário. /// </returns> public override bool CanConvertTo(EMathematicsType mathematicsType) { return(this.mathematicsType.Equals(mathematicsType)); }
/// <summary> /// Instancia um novo objecto do tipo <see cref="AMathematicsFunctionObject"/>. /// </summary> /// <param name="mathematicsType">O tipo.</param> public AMathematicsFunctionObject(EMathematicsType mathematicsType) : base(mathematicsType, true) { }
/// <summary> /// Instancia um novo objecto do tipo <see cref="AMathematicsConditionObject"/>. /// </summary> /// <param name="conditionType">O tipo de condição.</param> /// <param name="mathematicsType">O tipo do objecto.</param> /// <param name="isFunctionObject">Um valor que indica se se trata de uma função.</param> public AMathematicsConditionObject( EMathematicsConditionType conditionType, EMathematicsType mathematicsType, bool isFunctionObject) : base(mathematicsType, false) { }
/// <summary> /// Obtém um objecto que resulta da conversão da instância corrente. /// </summary> /// <param name="mathematicsType">O tipo de objecto no qual se pretende converter.</param> /// <returns>O objecto convertido.</returns> public abstract AMathematicsObject ConvertTo(EMathematicsType mathematicsType);
/// <summary> /// Determina se é possível converter a instância corrente no tipo especificado. /// </summary> /// <param name="mathematicsType">O tipo.</param> /// <returns>Verdadeiro caso seja possível converter a instância e falso caso contrário.</returns> public abstract bool CanConvertTo(EMathematicsType mathematicsType);
/// <summary> /// Instancia um novo objecto do tipo <see cref="AMathematicsObject"/>. /// </summary> /// <param name="mathematicsType">O tipo.</param> /// <param name="isFunctionObject">Um valor que indica se se trata de uma função.</param> public AMathematicsObject(EMathematicsType mathematicsType, bool isFunctionObject) { this.mathematicsType = mathematicsType; this.isFunctionObject = isFunctionObject; }
/// <summary> /// Obtém um objecto que resulta da conversão da instância corrente. /// </summary> /// <param name="mathematicsType">O tipo de objecto no qual se pretende converter.</param> /// <returns> /// O objecto convertido. /// </returns> public override AMathematicsObject ConvertTo(EMathematicsType mathematicsType) { throw new NotImplementedException(); }
/// <summary> /// Determina se é possível converter a instância corrente no tipo especificado. /// </summary> /// <param name="mathematicsType">O tipo.</param> /// <returns> /// Verdadeiro caso seja possível converter a instância e falso caso contrário. /// </returns> public override bool CanConvertTo(EMathematicsType mathematicsType) { throw new NotImplementedException(); }
/// <summary> /// Determina se é possível converter a instância corrente no tipo especificado. /// </summary> /// <param name="mathematicsType">O tipo.</param> /// <returns> /// Verdadeiro caso seja possível converter a instância e falso caso contrário. /// </returns> public override bool CanConvertTo(EMathematicsType mathematicsType) { if (mathematicsType == EMathematicsType.STRING_VALUE) { return(true); } else if (mathematicsType == EMathematicsType.INTEGER_VALUE) { var temp = 0; if (int.TryParse(this.value, out temp)) { return(true); } } else if (mathematicsType == EMathematicsType.ASSIGN) { throw new NotImplementedException(); } else if (mathematicsType == EMathematicsType.BOOLEAN_VALUE) { var temp = true; if (bool.TryParse(this.value, out temp)) { return(true); } } else if (mathematicsType == EMathematicsType.CONDITION) { throw new NotImplementedException(); } else if (mathematicsType == EMathematicsType.DOUBLE_VALUE) { var temp = 0.0; if (double.TryParse(this.value, NumberStyles.Number, CultureInfo.InvariantCulture.NumberFormat, out temp)) { return(true); } } else if (mathematicsType == EMathematicsType.EMPTY) { if (string.IsNullOrWhiteSpace(this.value)) { return(true); } } else if (mathematicsType == EMathematicsType.LIST) { throw new NotImplementedException(); } else if (mathematicsType == EMathematicsType.NAME) { } else if (mathematicsType == EMathematicsType.POLYNOMIAL) { throw new NotImplementedException(); } else if (mathematicsType == EMathematicsType.RANGE) { throw new NotImplementedException(); } else if (mathematicsType == EMathematicsType.SET) { throw new NotImplementedException(); } return(false); }
/// <summary> /// Obtém um objecto que resulta da conversão da instância corrente. /// </summary> /// <param name="mathematicsType">O tipo de objecto no qual se pretende converter.</param> /// <returns> /// O objecto convertido. /// </returns> /// <exception cref="ExpressionInterpreterException"></exception> public override AMathematicsObject ConvertTo(EMathematicsType mathematicsType) { if (mathematicsType == EMathematicsType.STRING_VALUE) { return(this); } else if (mathematicsType == EMathematicsType.INTEGER_VALUE) { var temp = 0; if (int.TryParse(this.value, out temp)) { return(new IntegerMathematicsObject() { Value = temp }); } } else if (mathematicsType == EMathematicsType.ASSIGN) { throw new NotImplementedException(); } else if (mathematicsType == EMathematicsType.BOOLEAN_VALUE) { var temp = true; if (bool.TryParse(this.value, out temp)) { return(new BooleanMathematicsObject() { Value = temp }); } } else if (mathematicsType == EMathematicsType.CONDITION) { throw new NotImplementedException(); } else if (mathematicsType == EMathematicsType.DOUBLE_VALUE) { var temp = 0.0; if (double.TryParse(this.value, NumberStyles.Number, CultureInfo.InvariantCulture.NumberFormat, out temp)) { return(new DoubleMathematicsObject() { Value = temp }); } } else if (mathematicsType == EMathematicsType.EMPTY) { if (string.IsNullOrWhiteSpace(this.value)) { return(new EmptyMathematicsObject()); } } else if (mathematicsType == EMathematicsType.LIST) { throw new NotImplementedException(); } else if (mathematicsType == EMathematicsType.NAME) { } else if (mathematicsType == EMathematicsType.POLYNOMIAL) { throw new NotImplementedException(); } else if (mathematicsType == EMathematicsType.RANGE) { throw new NotImplementedException(); } else if (mathematicsType == EMathematicsType.SET) { throw new NotImplementedException(); } throw new ExpressionInterpreterException(string.Format("Can't convert from type {0} to type {1}.", this.mathematicsType, mathematicsType)); }