Esempio n. 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)
        {
            EscherRecordFactory 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;
            }
        }
Esempio n. 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 +
                   "  options: 0x" + HexDump.ToHex(Options) + nl +
                   "  recordId: 0x" + HexDump.ToHex(RecordId) + nl +
                   "  numchildren: " + ChildRecords.Count + nl +
                   theDumpHex +
                   children.ToString());
        }
Esempio n. 3
0
        /// <summary>
        /// Toes the string.
        /// </summary>
        /// <param name="indent">The indent.</param>
        /// <returns></returns>
        public String ToString(String indent)
        {
            String nl = Environment.NewLine;

            StringBuilder children = new StringBuilder();

            if (ChildRecords.Count > 0)
            {
                children.Append("  children: " + nl);

                int count = 0;
                for (IEnumerator iterator = ChildRecords.GetEnumerator(); iterator.MoveNext();)
                {
                    String newIndent = indent + "   ";

                    EscherRecord record = (EscherRecord)iterator.Current;
                    children.Append(newIndent + "Child " + count + ":" + nl);

                    if (record is EscherContainerRecord)
                    {
                        EscherContainerRecord ecr = (EscherContainerRecord)record;
                        children.Append(ecr.ToString(newIndent));
                    }
                    else
                    {
                        children.Append(record.ToString());
                    }
                    count++;
                }
            }

            return
                (indent + this.GetType().Name + " (" + RecordName + "):" + nl +
                 indent + "  isContainer: " + IsContainerRecord + nl +
                 indent + "  options: 0x" + HexDump.ToHex(Options) + nl +
                 indent + "  recordId: 0x" + HexDump.ToHex(RecordId) + nl +
                 indent + "  numchildren: " + ChildRecords.Count + nl +
                 indent + children.ToString());
        }