示例#1
0
        // Processes the given file.
        private void ProcessFile(string filePath)
        {
            bool alreadyProcessed;

            // If the file processor is disposed or the
            // file no longer exists, return immediately
            if (m_disposed || !File.Exists(filePath))
            {
                return;
            }

            // Process the file at the given file path
            alreadyProcessed = m_processedFiles.Contains(filePath);

            if (OnProcessing(filePath, alreadyProcessed))
            {
                // If the handler requeuests a requeue,
                // requeue the file after a 250 millisecond delay.
                DelayLockAndProcess(filePath);
            }
            else if (!alreadyProcessed)
            {
                // Update the list of processed files
                // and save it back to the cache
                m_processedFiles.Add(filePath);
            }
        }
示例#2
0
 public void AddTest()
 {
     using (FileBackedHashSet <int> hashSet = new FileBackedHashSet <int>())
     {
         hashSet.Add(0);
         Assert.IsTrue(hashSet.Contains(0));
         Assert.AreEqual(hashSet.Count, 1);
     }
 }
示例#3
0
 public void AddTest()
 {
     using (FileBackedHashSet<int> hashSet = new FileBackedHashSet<int>())
     {
         hashSet.Add(0);
         Assert.IsTrue(hashSet.Contains(0));
         Assert.AreEqual(hashSet.Count, 1);
     }
 }
示例#4
0
        public void CompactTest()
        {
            using (FileBackedHashSet <int> hashSet = new FileBackedHashSet <int>())
            {
                for (int i = 0; i < 10000; i += 4)
                {
                    hashSet.Add(i);

                    if (i % 100 == 0)
                    {
                        hashSet.Remove(i);
                    }

                    if (i % 400 == 0)
                    {
                        hashSet.Add(i);
                    }
                }

                hashSet.Compact();

                for (int i = 0; i < 10000; i++)
                {
                    if (i % 400 == 0)
                    {
                        Assert.IsTrue(hashSet.Contains(i));
                    }
                    else if (i % 100 == 0)
                    {
                        Assert.IsFalse(hashSet.Contains(i));
                    }
                    else if (i % 4 == 0)
                    {
                        Assert.IsTrue(hashSet.Contains(i));
                    }
                    else
                    {
                        Assert.IsFalse(hashSet.Contains(i));
                    }
                }
            }
        }
示例#5
0
 public void RemoveTest()
 {
     using (FileBackedHashSet <int> hashSet = new FileBackedHashSet <int>())
     {
         hashSet.Add(0);
         Assert.IsTrue(hashSet.Contains(0));
         hashSet.Remove(0);
         Assert.IsFalse(hashSet.Contains(0));
         Assert.AreEqual(hashSet.Count, 0);
     }
 }
示例#6
0
 public void RemoveTest()
 {
     using (FileBackedHashSet<int> hashSet = new FileBackedHashSet<int>())
     {
         hashSet.Add(0);
         Assert.IsTrue(hashSet.Contains(0));
         hashSet.Remove(0);
         Assert.IsFalse(hashSet.Contains(0));
         Assert.AreEqual(hashSet.Count, 0);
     }
 }
示例#7
0
        public void ClearTest()
        {
            using (FileBackedHashSet <int> hashSet = new FileBackedHashSet <int>())
            {
                for (int i = 0; i < 100; i++)
                {
                    hashSet.Add(i);
                }

                Assert.AreEqual(hashSet.Count, 100);
                hashSet.Clear();
                Assert.AreEqual(hashSet.Count, 0);
            }
        }
示例#8
0
        public void IntersectWithTest()
        {
            using (FileBackedHashSet<int> hashSet = new FileBackedHashSet<int>())
            {
                for (int i = 0; i < 10; i++)
                    hashSet.Add(i);

                hashSet.IntersectWith(Enumerable.Range(5, 10));

                for (int i = 5; i < 10; i++)
                    Assert.IsTrue(hashSet.Contains(i), i.ToString());

                Assert.AreEqual(hashSet.Count, 5);
            }
        }
示例#9
0
        public void SetEqualsTest()
        {
            using (FileBackedHashSet <int> hashSet = new FileBackedHashSet <int>())
            {
                for (int i = 0; i < 5; i++)
                {
                    hashSet.Add(i);
                }

                Assert.IsTrue(hashSet.SetEquals(Enumerable.Range(0, 5)), "Equal");
                Assert.IsFalse(hashSet.SetEquals(Enumerable.Range(0, 10)), "Superset");
                Assert.IsFalse(hashSet.SetEquals(Enumerable.Range(0, 3)), "Subset");
                Assert.IsFalse(hashSet.SetEquals(Enumerable.Range(1, 5)), "Overlap");
                Assert.IsFalse(hashSet.SetEquals(Enumerable.Range(5, 5)), "Disjoint");
            }
        }
示例#10
0
        public void ExceptWithTest()
        {
            using (FileBackedHashSet <int> hashSet = new FileBackedHashSet <int>())
            {
                for (int i = 0; i < 10; i++)
                {
                    hashSet.Add(i);
                }

                hashSet.ExceptWith(Enumerable.Range(5, 10));

                for (int i = 0; i < 5; i++)
                {
                    Assert.IsTrue(hashSet.Contains(i), i.ToString());
                }

                Assert.AreEqual(hashSet.Count, 5);
            }
        }
示例#11
0
        public void CopyToTest()
        {
            int[] array;

            using (FileBackedHashSet <int> hashSet = new FileBackedHashSet <int>())
            {
                for (int i = 1; i <= 100; i++)
                {
                    hashSet.Add(i);
                }

                Assert.AreEqual(hashSet.Count, 100);

                array = new int[hashSet.Count];
                hashSet.CopyTo(array, 0);

                foreach (int i in array)
                {
                    Assert.IsTrue(hashSet.Contains(i));
                }
            }
        }
示例#12
0
        public void CompactTest()
        {
            using (FileBackedHashSet<int> hashSet = new FileBackedHashSet<int>())
            {
                for (int i = 0; i < 10000; i += 4)
                {
                    hashSet.Add(i);

                    if (i % 100 == 0)
                        hashSet.Remove(i);

                    if (i % 400 == 0)
                        hashSet.Add(i);
                }

                hashSet.Compact();

                for (int i = 0; i < 10000; i++)
                {
                    if (i % 400 == 0)
                        Assert.IsTrue(hashSet.Contains(i));
                    else if (i % 100 == 0)
                        Assert.IsFalse(hashSet.Contains(i));
                    else if (i % 4 == 0)
                        Assert.IsTrue(hashSet.Contains(i));
                    else
                        Assert.IsFalse(hashSet.Contains(i));
                }
            }
        }
示例#13
0
        public void CopyToTest()
        {
            int[] array;

            using (FileBackedHashSet<int> hashSet = new FileBackedHashSet<int>())
            {
                for (int i = 1; i <= 100; i++)
                    hashSet.Add(i);

                Assert.AreEqual(hashSet.Count, 100);

                array = new int[hashSet.Count];
                hashSet.CopyTo(array, 0);

                foreach (int i in array)
                    Assert.IsTrue(hashSet.Contains(i));
            }
        }
示例#14
0
        public void ClearTest()
        {
            using (FileBackedHashSet<int> hashSet = new FileBackedHashSet<int>())
            {
                for (int i = 0; i < 100; i++)
                    hashSet.Add(i);

                Assert.AreEqual(hashSet.Count, 100);
                hashSet.Clear();
                Assert.AreEqual(hashSet.Count, 0);
            }
        }
示例#15
0
        public void SetEqualsTest()
        {
            using (FileBackedHashSet<int> hashSet = new FileBackedHashSet<int>())
            {
                for (int i = 0; i < 5; i++)
                    hashSet.Add(i);

                Assert.IsTrue(hashSet.SetEquals(Enumerable.Range(0, 5)), "Equal");
                Assert.IsFalse(hashSet.SetEquals(Enumerable.Range(0, 10)), "Superset");
                Assert.IsFalse(hashSet.SetEquals(Enumerable.Range(0, 3)), "Subset");
                Assert.IsFalse(hashSet.SetEquals(Enumerable.Range(1, 5)), "Overlap");
                Assert.IsFalse(hashSet.SetEquals(Enumerable.Range(5, 5)), "Disjoint");
            }
        }