protected void WriteString(byte[] array, OperationInfo info, string str) { if (str == null) { WriteShort(array, info, -1); } else if (str.Length > 0) { byte[] strArray = Encoding.UTF8.GetBytes(str); WriteShort(array, info, (short)strArray.Length); Array.Copy(strArray, 0, array, info.index, strArray.Length); info.index += strArray.Length; } else { WriteShort(array, info, 0); } }
protected void WriteBool(byte[] array, OperationInfo info, bool @bool) { array[info.index] = @bool ? (byte)1 : (byte)0; info.index++; }
protected void WriteByte(byte[] array, OperationInfo info, byte bt) { array[info.index] = bt; info.index++; }
protected void WritePath(byte[] array, OperationInfo info, IEnumerable <string> path) { string result = string.Join('.', path); WriteString(array, info, result); }
/// <summary> /// Запись информации в массив /// </summary> /// <param name="array"></param> /// <param name="info"></param> public abstract void Process(byte[] array, OperationInfo info);