private void InitIndexSink(FileHashDB sender)
 {
     OnIndexRebuilt -= new OnIndexRebuiltHandler(InitIndexSink);
     if (OnReady != null)
     {
         OnReady(this, null);
     }
 }
        internal DataBlock(FileHashDB READER_sender, int offset, OnReadHandler rCB, object Tag)
        {
            OnRead += rCB;
            _Tag    = Tag;
            CB      = new AsyncCallback(ReadBlockSink);
            f       = READER_sender;

            f.SeekLock.WaitOne();
            f.fstream.Seek((long)offset, SeekOrigin.Begin);
            f.fstream.BeginRead(buffer, 0, 512, CB, offset);
            f.SeekLock.ReleaseMutex();
        }
Exemplo n.º 3
0
        internal DataBlock(FileHashDB READER_sender, int offset, OnReadHandler rCB, object Tag)
        {
            OnRead += rCB;
            _Tag = Tag;
            CB = new AsyncCallback(ReadBlockSink);
            f = READER_sender;

            f.SeekLock.WaitOne();
            f.fstream.Seek((long)offset,SeekOrigin.Begin);
            f.fstream.BeginRead(buffer,0,512,CB,offset);
            f.SeekLock.ReleaseMutex();
        }
        private void ReadObjectSink(FileHashDB sender, string KEY, byte[] buffer, object Tag)
        {
            object RetObj = null;

            if (buffer.Length > 0)
            {
                MemoryStream ostream = new MemoryStream(buffer);
                RetObj = formatter.Deserialize(ostream);
                object[] state = (object[])Tag;
                if (state[1] != null)
                {
                    ((OnReadObjectHandler)state[1])(this, KEY, RetObj, state[0]);
                }
            }
        }
Exemplo n.º 5
0
 private void ReadObjectSink(FileHashDB sender, string KEY, byte[] buffer, object Tag)
 {
     object RetObj = null;
     if(buffer.Length>0)
     {
         MemoryStream ostream = new MemoryStream(buffer);
         RetObj = formatter.Deserialize(ostream);
         object[] state = (object[])Tag;
         if(state[1]!=null)
         {
             ((OnReadObjectHandler)state[1])(this,KEY,RetObj,state[0]);
         }
     }
 }
Exemplo n.º 6
0
 private void InitIndexSink(FileHashDB sender)
 {
     OnIndexRebuilt -= new OnIndexRebuiltHandler(InitIndexSink);
     if(OnReady!=null) OnReady(this, null);
 }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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));
 }
Exemplo n.º 9
0
 public void ReadObject(string KEY, object Tag, FileHashDB.OnReadObjectHandler CB)
 {
     ReadRecord(KEY,new object[2]{Tag,CB},ObjectReadCB);
 }
Exemplo n.º 10
0
 public void ReadObject(int Position, object Tag, FileHashDB.OnReadObjectHandler CB)
 {
     ReadRecord(Position,new Object[2]{Tag,CB},ObjectReadCB);
 }
 internal DataBlock(int BlockOffset, FileHashDB WRITER_sender)
 {
     CB     = new AsyncCallback(WriteBlockSink);
     f      = WRITER_sender;
     OFFSET = BlockOffset;
 }
Exemplo n.º 12
0
 internal DataBlock(int BlockOffset, FileHashDB WRITER_sender)
 {
     CB = new AsyncCallback(WriteBlockSink);
     f = WRITER_sender;
     OFFSET = BlockOffset;
 }