namespace com.azkoss.excellite { using System; /// ///Formula token for holding function with variable arguments count. /// internal class FunctionVarFormulaToken : FormulaToken { // Methods /// ///Initializes a new instance of the class. /// ///The code. public FunctionVarFormulaToken(FormulaTokenCode code) : base(code, 4, FormulaTokenType.Function) { } /// ///Convert formula token to array of byte representation. /// ///formula token' array of byte representation public override byte[] ConvertToBytes() { byte[] buffer1 = base.ConvertToBytes(); buffer1[1] = this.argumentsCount; byte[] buffer2 = BitConverter.GetBytes(this.function.Code); buffer2.CopyTo(buffer1, 2); return buffer1; } /// ///Make custom delay initialize. /// ///The data for initialization which is unique for each formula token. public override void DelayInitialize(object[] data) { this.function = FormulaFunctionsTable.Instance[data[0] as string]; this.argumentsCount = (byte) data[1]; } /// ///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.argumentsCount = rpnBytes[startIndex]; ushort num1 = BitConverter.ToUInt16(rpnBytes, startIndex + 1); this.function = FormulaFunctionsTable.Instance[num1]; } /// ///Convert formula token to string representation. /// ///formula token string representation public override string ToString() { return this.function.Name.ToUpper(); } // Properties public byte ArgumentsCount { get { return this.argumentsCount; } } public FormulaFunctionInfo Function { get { return this.function; } } // Fields private byte argumentsCount; private FormulaFunctionInfo function; } }