示例#1
0
        /// <exception cref="System.IO.IOException"/>
        internal void WriteInternal(IBufferObjectDataOutput output, IPortable p)
        {
            var cd = _context.LookupOrRegisterClassDefinition(p);

            output.Write(cd.Version);
            var writer = new DefaultPortableWriter(this, output, cd);

            p.WritePortable(writer);
            writer.End();
        }
        /// <exception cref="System.IO.IOException" />
        public DefaultPortableWriter(PortableSerializer serializer, IBufferObjectDataOutput @out, IClassDefinition cd)
        {
            _serializer    = serializer;
            _out           = @out;
            _cd            = cd;
            _writtenFields = new HashSet <string>(); //cd.GetFieldCount()
            _begin         = @out.Position;
            // room for final offset
            @out.WriteZeroBytes(4);
            @out.Write(cd.GetFieldCount());
            _offset = @out.Position;
            // one additional for raw data
            var fieldIndexesLength = (cd.GetFieldCount() + 1) * BytesExtensions.SizeOfInt;

            @out.WriteZeroBytes(fieldIndexesLength);
        }
 /// <exception cref="System.IO.IOException" />
 public virtual void WriteInt(string fieldName, int value)
 {
     SetPosition(fieldName, FieldType.Int);
     _out.Write(value);
 }