namespace com.azkoss.excellite { using System; using System.Text; /// ///Formula token for holding string. /// internal class StrFormulaToken : FormulaToken { // Methods /// ///Initializes a new instance of the class. /// public StrFormulaToken() : base(FormulaTokenCode.Str, 9, FormulaTokenType.Operand) { } /// ///Convert formula token to array of byte representation. /// ///formula token' array of byte representation public override byte[] ConvertToBytes() { byte[] buffer1 = new byte[(this.value.Length * 2) + 3]; buffer1[0] = base.Code; buffer1[1] = (byte) this.value.Length; buffer1[2] = 1; byte[] buffer2 = Encoding.Unicode.GetBytes(this.value); buffer2.CopyTo(buffer1, 3); 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 = (string) 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.isCompressed = rpnBytes[startIndex + 1] == 1; byte num1 = rpnBytes[startIndex]; this.value = Utilities.ReadString(this.isCompressed, rpnBytes, startIndex + 2, num1); } /// ///Convert formula token to string representation. /// ///formula token string representation public override string ToString() { return this.value; } // Properties public bool IsCompressed { get { return this.isCompressed; } } public override int Size { get { int num1 = this.value.Length; if (!this.isCompressed) { return (num1 + 3); } return ((num1 * 2) + 3); } } public string Value { get { return this.value; } } // Fields private bool isCompressed; public const char StartMark = '"'; private string value; } }