Ejemplo n.º 1
0
        public int GetNextKey()
        {
            int RecordPointer = int.MaxValue;

            #region
            try
            {
                CurrentKey++;

                if (CurrentKey == NumberOfKeys)
                {
                    CurrentKey = (int)NumberOfKeys - 1;
                    return(-2);
                }

                RecordPointer = RecordOffset + CurrentKey * RecordSize;
                FileStreamData.Seek(RecordPointer, 0);

                Key   = BinaryReaderData.ReadString();
                Flag  = BinaryReaderData.ReadBoolean();
                Value = BinaryReaderData.ReadString();

                return(RecordPointer);
            }
            catch (Exception e)
            {
                StringLastError = e.Message;
                return(-3);
            }
            #endregion
        }
Ejemplo n.º 2
0
        public int GetPrevKey()
        {
            int RecordPointer = int.MaxValue;

            #region
            try
            {
                CurrentKey--;

                if (CurrentKey < 0)
                {
                    CurrentKey = 0;
                    return(-1);
                }

                RecordPointer = RecordOffset + CurrentKey * RecordSize;

                FileStreamData.Seek(RecordPointer, 0);

                Key   = BinaryReaderData.ReadString();
                Flag  = BinaryReaderData.ReadBoolean();
                Value = BinaryReaderData.ReadString();

                return(RecordPointer);
            }
            catch (Exception e)
            {
                StringLastError = e.Message;
                return(-3);
            }
            #endregion
        }
Ejemplo n.º 3
0
        public uint FindKey(string P_key)
        {
            uint RecordPointer = uint.MaxValue, IndexPointer = uint.MaxValue;

            KeyBytes    = ASCIIEncoding.UTF8.GetBytes(P_key);
            ByteIndex   = 0;
            IndexOffset = 0;

            for (ByteIndex = 0; ByteIndex < KeyBytes.Length; ByteIndex++)
            {
                #region
                count++;
                IndexPosition = (uint)(IndexOffset + (KeyBytes[ByteIndex] - 32) * 8);

                try
                {
                    FileStreamIdx.Seek(IndexPosition, 0);
                    RecordPointer = BinaryReaderIdx.ReadUInt32();
                    IndexPointer  = BinaryReaderIdx.ReadUInt32();

                    if (IndexPointer == uint.MaxValue)
                    {
                        return(uint.MaxValue);
                    }

                    FileStreamData.Seek(RecordPointer, 0);

                    Key   = BinaryReaderData.ReadString();
                    Flag  = BinaryReaderData.ReadBoolean();
                    Value = BinaryReaderData.ReadString();

                    if (Key.Equals(P_key) && !Flag)
                    {
                        return(RecordPointer);
                    }
                    else
                    {
                        IndexOffset = IndexPointer;
                    }
                }
                catch (Exception e)
                {
                    StringLastError = e.Message;
                    return(uint.MaxValue);;
                }
                #endregion
            }

            return(uint.MaxValue);
        }