コード例 #1
0
        public int WriteObject(string KEY, object ObjectToWrite, object Tag, FileHashDB.OnWriteHandler CB)
        {
            MemoryStream ostream = new MemoryStream();

            formatter.Serialize(ostream, ObjectToWrite);
            byte[] buffer = ostream.ToArray();
            return(WriteRecord(KEY, buffer, 0, buffer.Length, Tag, CB));
        }
コード例 #2
0
        public int WriteRecord(string KEY, byte[] buffer, int offset, int count, object Tag, FileHashDB.OnWriteHandler WriteCB)
        {
            DataBlock d = GetFreeBlock();

            d._Tag     = WriteCB;
            d.OnWrite += new DataBlock.OnWriteHandler(WriteSink);
            long h = 0;

            lock (CBMap)
            {
                h        = handle++;
                CBMap[h] = new object[2] {
                    KEY, Tag
                };
            }

            if (Map != null)
            {
                lock (Map)
                {
                    Map[KEY] = d.OFFSET;
                }
            }

            d.Write(KEY, buffer, offset, count, h);
            return(d.OFFSET);
        }