Пример #1
0
        /// <summary>
        /// Decodes the escher stream from a byte array and dumps the results to
        /// a print stream.
        /// </summary>
        /// <param name="data">The data array containing the escher records.</param>
        /// <param name="offset">The starting offset within the data array.</param>
        /// <param name="size">The number of bytes to Read.</param>
        public void Dump(byte[] data, int offset, int size)
        {
            IEscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
            int pos = offset;

            while (pos < offset + size)
            {
                EscherRecord r         = recordFactory.CreateRecord(data, pos);
                int          bytesRead = r.FillFields(data, pos, recordFactory);
                Console.WriteLine(r.ToString());
                pos += bytesRead;
            }
        }
Пример #2
0
        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override String ToString()
        {
            String nl = Environment.NewLine;

            StringBuilder children = new StringBuilder();

            if (ChildRecords.Count > 0)
            {
                children.Append("  children: " + nl);
                for (IEnumerator iterator = ChildRecords.GetEnumerator(); iterator.MoveNext();)
                {
                    EscherRecord record = (EscherRecord)iterator.Current;
                    children.Append(record.ToString());
                    children.Append(nl);
                }
            }

            String theDumpHex = "";

            try
            {
                if (_thedata.Length != 0)
                {
                    theDumpHex  = "  Extra Data(" + _thedata.Length + "):" + nl;
                    theDumpHex += HexDump.Dump(_thedata, 0, 0);
                }
            }
            catch (Exception)
            {
                theDumpHex = "Error!!";
            }

            return(this.GetType().Name + ":" + nl +
                   "  isContainer: " + IsContainerRecord + nl +
                   "  version: 0x" + HexDump.ToHex(Version) + nl +
                   "  instance: 0x" + HexDump.ToHex(Instance) + nl +
                   "  recordId: 0x" + HexDump.ToHex(RecordId) + nl +
                   "  numchildren: " + ChildRecords.Count + nl +
                   theDumpHex +
                   children.ToString());
        }