namespace com.azkoss.excellite { using System; /// ///Formula token for holding bool. /// internal class BoolFormulaToken : FormulaToken { // Methods static BoolFormulaToken() { BoolFormulaToken.True = "TRUE"; BoolFormulaToken.False = "FALSE"; } /// ///Initializes a new instance of the class. /// public BoolFormulaToken() : base(FormulaTokenCode.Bool, 2, FormulaTokenType.Operand) { } /// ///Convert formula token to array of byte representation. /// ///formula token' array of byte representation public override byte[] ConvertToBytes() { byte[] buffer1 = base.ConvertToBytes(); byte[] buffer2 = BitConverter.GetBytes(this.value); buffer2.CopyTo(buffer1, 1); return buffer1; } /// ///Make custom delay initialize. /// ///The data for initialization which is unique for each formula token. public override void DelayInitialize(object[] data) { this.value = (bool) data[0]; } /// ///Initialize formula token by reading input data from array of bytes /// ///input data, array of bytes ///start position for array of bytes to read from public override void Read(byte[] rpnBytes, int startIndex) { this.value = BitConverter.ToBoolean(rpnBytes, startIndex); } /// ///Convert formula token to string representation. /// ///formula token string representation public override string ToString() { if (!this.value) { return BoolFormulaToken.False; } return BoolFormulaToken.True; } // Properties public bool Value { get { return this.value; } } // Fields public static string False; public static string True; private bool value; } }