/// <summary> /// Strongly determines the node's type, if possible. /// </summary> /// <param name="type">The type to determine to.</param> public sealed override void DetermineStrongly(SupportedValueType type) { if (type != SupportedValueType.Numeric) { throw new ExpressionNotValidLogicallyException(); } }
/// <summary> /// Determines the type of the parameter. /// </summary> /// <param name="newType">The new type.</param> /// <exception cref="ArgumentException">The new type is not valid.</exception> public void DetermineType(SupportedValueType newType) { switch (newType) { case SupportedValueType.Boolean: ChangeReturnType(SupportedValueType.Boolean); return; case SupportedValueType.ByteArray: ChangeReturnType(SupportedValueType.ByteArray); return; case SupportedValueType.String: ChangeReturnType(SupportedValueType.String); return; case SupportedValueType.Numeric: ChangeReturnType(SupportedValueType.Numeric); return; default: throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.ParameterTypeNotRecognized, Name), Name); } void ChangeReturnType(SupportedValueType newReturnType) { if (ReturnType == newReturnType) { return; } if (ReturnType == SupportedValueType.Unknown) { if (alreadyCompiled) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.ParameterAlreadyCompiled, Name)); } int i1 = (int)newReturnType, i2 = (int)SupportedReturnType; if ((i1 & i2) == 0) { throw new ExpressionNotValidLogicallyException(string.Format(CultureInfo.CurrentCulture, Resources.ParameterRequiredOfMismatchedTypes, Name)); } ReturnType = newReturnType; SupportedReturnType = (SupportableValueType)i1; } else { throw new ExpressionNotValidLogicallyException(string.Format(CultureInfo.CurrentCulture, Resources.ParameterRequiredOfMismatchedTypes, Name)); } } }
/// <summary> /// Strongly determines the node's type, if possible. /// </summary> /// <param name="type">The type to determine to.</param> public override void DetermineStrongly(SupportedValueType type) { if (type is SupportedValueType.Boolean or SupportedValueType.Numeric) { Left.DetermineStrongly(type); Right.DetermineStrongly(type); EnsureCompatibleOperands( Left, Right); }
/// <summary> /// Strongly determines the node's type, if possible. /// </summary> /// <param name="type">The type to determine to.</param> public abstract void DetermineStrongly(SupportedValueType type);
/// <summary> /// Strongly determines the node's type, if possible. /// </summary> /// <param name="type">The type to determine to.</param> public override void DetermineStrongly(SupportedValueType type) => parametersRegistry.AdvertiseParameter(Name).DetermineType(type);