示例#1
0
        private WriteBuffer CloseTag()
        {
            if (this.writers.Count <= 1)
            {
                throw new SWFModellerException(
                          SWFModellerError.Internal,
                          "Call to CloseTag when no tag was open.");
            }

            WriteBuffer tagWriter = this.writers.Peek();

            tagWriter.Align8();
            byte[] tagData = tagWriter.Data;
            int    tagCode = (int)tagWriter.Tag;

#if DEBUG
            this.LogMessage("Body length of " + tagWriter.Tag.ToString() + " " + tagData.Length + " bytes on " + tagWriter.LogData, true);
#endif
            this.writers.Pop();

            tagWriter = this.writers.Peek();
            tagWriter.Align8();

            if (tagData.Length >= 63)
            {
                /* Long record header */
                int hdr = (tagCode << 6) | 0x3f;
                tagWriter.WriteUI16((uint)hdr);
                tagWriter.WriteSI32(tagData.Length);
            }
            else
            {
                /* Short record header */
                int hdr = (tagCode << 6) | tagData.Length;
                tagWriter.WriteUI16((uint)hdr);
            }

            tagWriter.Write(tagData, 0, tagData.Length);

            return(tagWriter);
        }