Exemplo n.º 1
0
        /*////////////////////////////////////////////////////////////////////////////////////////*/

        public void Enqueue(string str)
        {
            lock (SyObject)
            {
                dataFile.AppendStringItem(str);

                count++;
                dataFile.WriteFileHeader(cursor, current, count);
            }
        }
Exemplo n.º 2
0
        /*////////////////////////////////////////////////////////////////////////////////////////*/

        public void Enqueue(object str)
        {
            lock (SyObject)
            {
                dataFile.AppendBinaryItem(Serialize(str));

                count++;
                dataFile.WriteFileHeader(cursor, current, count);
            }
        }
Exemplo n.º 3
0
        public UniqueStringQueuedFile(string fileName, bool caseSensitive)
        {
            CaseSensitive = caseSensitive;
            FileName      = fileName;
            dataFile      = new StreamRW(fileName);
            SyObject      = new object();

            if (dataFile.Length == 0)
            {
                dataFile.WriteFileHeader(0, 0, 0);
                count = current = 0;
                dataFile.Seek(0, SeekOrigin.End);
                realCursor = cursor = (int)dataFile.Position;
                AllItems   = new Queue <string>();
            }
            else
            {
                var tmp = dataFile.ReadFileHeader();
                count       = tmp.Count;
                realCurrent = current = tmp.Current;
                realCursor  = cursor = tmp.Position;

                AllItems = dataFile.ReadAllStringInQueue();

                dataFile.Seek(cursor, SeekOrigin.Begin);
            }
        }
Exemplo n.º 4
0
        /*////////////////////////////////////////////////////////////////////////////////////////*/

        public void Enqueue(string str)
        {
            if (string.IsNullOrEmpty(str))
            {
                return;
            }
            var testStr = CaseSensitive == true ? str : str.ToLower();

            lock (SyObject)
            {
                if (AllItems.Contains(testStr))
                {
                    return;
                }
                AllItems.Enqueue(testStr);

                dataFile.AppendStringItem(str);
                count++;
                dataFile.WriteFileHeader(cursor, current, count);
            }
        }
Exemplo n.º 5
0
        /*////////////////////////////////////////////////////////////////////////////////////////*/

        #region Ctor

        public StringQueuedFile(string fileName)
        {
            FileName = fileName;
            dataFile = new StreamRW(fileName);
            SyObject = new object();

            if (dataFile.Length == 0)
            {
                dataFile.WriteFileHeader(0, 0, 0);
                count = current = 0;
                dataFile.Seek(0, SeekOrigin.End);
                realCursor = cursor = (int)dataFile.Position;
            }
            else
            {
                var tmp = dataFile.ReadFileHeader();
                count       = tmp.Count;
                realCurrent = current = tmp.Current;
                realCursor  = cursor = tmp.Position;

                dataFile.Seek(cursor, SeekOrigin.Begin);
            }
        }