
            {
                uint pos = Expand( sizeof(uint) );

                m_context.Write( pos, val.ToUInt32() );
            }

            public void Write( IntPtr val )
            {
                uint pos = Expand( sizeof(uint) );

                m_context.Write( pos, (uint)val.ToInt32() );
            }

            //--//

            public void Write( byte[] valArray )
            {
                uint pos = Expand( (uint)(valArray.Length * sizeof(byte)) );

                m_context.Write( pos, valArray );
            }

            public void Write( char[] valArray )
            {
                uint pos = Expand( (uint)(valArray.Length * sizeof(char)) );

                m_context.Write( pos, valArray );
            }

            public void Write( int[] valArray )
            {
                uint pos = Expand( (uint)(valArray.Length * sizeof(int)) );

                m_context.Write( pos, valArray );
            }

            public void Write( uint[] valArray )
            {
                uint pos = Expand( (uint)(valArray.Length * sizeof(uint)) );

                m_context.Write( pos, valArray );
            }

            //--//

            public bool WriteGeneric( object val )
            {
                if(val!= null)
                {
                    Type t = val.GetType();

                    if(t.IsEnum)
                    {
                        t = Enum.GetUnderlyingType( t );
                    }

                    if(t == typeof(bool   )) { Write( (bool   )val ); return true; }
                    if(t == typeof(byte   )) { Write( (byte   )val ); return true; }
                    if(t == typeof(ushort )) { Write( (ushort )val ); return true; }
                    if(t == typeof(uint   )) { Write( (uint   )val ); return true; }
                    if(t == typeof(ulong  )) { Write( (ulong  )val ); return true; }
                    if(t == typeof(sbyte  )) { Write( (sbyte  )val ); return true; }
                    if(t == typeof(short  )) { Write( (short  )val ); return true; }
                    if(t == typeof(int    )) { Write( (int    )val ); return true; }
                    if(t == typeof(long   )) { Write( (long   )val ); return true; }
                    if(t == typeof(char   )) { Write( (char   )val ); return true; }
                    if(t == typeof(float  )) { Write( (float  )val ); return true; }
                    if(t == typeof(double )) { Write( (double )val ); return true; }
                    if(t == typeof(UIntPtr)) { Write( (UIntPtr)val ); return true; }
                    if(t == typeof(IntPtr )) { Write( (IntPtr )val ); return true; }
                    if(t == typeof(byte[] )) { Write( (byte[] )val ); return true; }
                    if(t == typeof(char[] )) { Write( (char[] )val ); return true; }
                    if(t == typeof(int [] )) { Write( (int [] )val ); return true; }
                    if(t == typeof(uint[] )) { Write( (uint[] )val ); return true; }
                }

                return false;
            }

            //--//

            public ImageAnnotation AddImageAnnotation( uint   size,
                                                       object val  )
            {
                return new GenericImageAnnotation( m_context, m_start + m_offset, size, val );
            }

            //--//

            private void CheckPosition()
            {
                if(m_end == uint.MaxValue)
                {
                    m_context.EnsureSize( m_start + m_offset );
                }
                else if(m_offset > this.Size)
                {
                    throw new IndexOutOfRangeException();
                }
            }

            private uint ExpandAndAnnotate( uint   size,
                                            object val  )
            {
                if(val!= null)
                {
                    AddImageAnnotation( size, val );
                }

                return Expand( size );
            }

            private uint Expand( uint size )
            {
                uint pos = m_start + m_offset;

                m_offset += size;

                CheckPosition();

                return pos;
            }

            //
            // Access Methods
            //

            public SequentialRegion Context
            {
                get
                {
                    return m_context;
                }
            }

            public uint Position
            {
                get
                {
                    return m_start + m_offset;
                }
            }

            public uint Offset
            {
                get
                {
                    return m_offset;
                }

                set
                {
                    m_offset = value;

                    CheckPosition();
                }
            }

            public uint Size
            {
                get
                {
                    return m_end - m_start;
                }
            }
        }

        //--//

        const uint AddressNotAssigned = 0xFFFFFFFFu;

        //
        // State
        //

        private Core                               m_owner;
        private object                             m_context;
        private Abstractions.PlacementRequirements m_placementRequirements;
        private UIntPtr                            m_baseAddress;
        private uint                               m_pointerOffset;
                                        
        private uint                               m_position;
        private uint                               m_size;
        private byte[]                             m_payload;
        private uint                               m_payloadCutoff;
        private List< ImageAnnotation >            m_annotationList;
                                        
        private PrettyDumper                       m_dumper;

        //
        // Constructor Methods
        //

        private SequentialRegion() // Default constructor required by TypeSystemSerializer.
        {
            m_annotationList = new List< ImageAnnotation >();
        }

        internal SequentialRegion( Core                               owner  ,
                                   object                             context,
                                   Abstractions.PlacementRequirements pr      ) : this()
        {
            m_owner                 = owner;
            m_context               = context;
            m_placementRequirements = pr;
            m_pointerOffset         = 0;

            m_position              = 0;
            m_size                  = 0;
            m_payloadCutoff         = uint.MaxValue;
            m_payload               = null;

            InvalidateBaseAddress();
        }

        //
        // Helper Methods
        //

        public void ApplyTransformation( TransformationContextForCodeTransformation context )
        {
            context.Push( this );

            context.Transform( ref m_owner                 );
            context.Transform( ref m_context               );
            context.Transform( ref m_placementRequirements );
            context.Transform( ref m_baseAddress           );
            context.Transform( ref m_pointerOffset         );
                                                     
            context.Transform( ref m_position              );
            context.Transform( ref m_size                  );
            context.Transform( ref m_payloadCutoff         );
            context.Transform( ref m_payload               );
            context.Transform( ref m_annotationList        );

            context.Pop();
        }

        //--//

        public void InvalidateBaseAddress()
        {
            m_baseAddress = new UIntPtr( AddressNotAssigned );
        }

        public void Clear()
        {
            m_pointerOffset = 0;

            m_position      = 0;
            m_size          = 0;
            m_payload       = null;
            m_annotationList.Clear();
        }

        //--//

        public uint AdjustSizeForAlignment( uint size )
        {
            return AddressMath.AlignToBoundary( size, m_owner.TypeSystem.PlatformAbstraction.MemoryAlignment );
        }

        public uint GetAbsoluteAddress( uint offset )
        {
            return this.ExternalAddress + offset;
        }

        public Section GetSectionOfVariableSize( uint alignment )
        {
            Section sec = new Section( this, m_position );

            return sec;
        }

        public Section GetSectionOfFixedSize( uint size )
        {
            size = AdjustSizeForAlignment( size );

            Section sec = new Section( this, m_position, size );

            Skip( size );

            return sec;
        }

        public void Skip( uint size )
        {
            m_position += size;

            EnsureSize( m_position );
        }

        //--//

        public byte ReadByte( uint offset )
        {