public static void Main()
    {
        Incrementer i1 = new Incrementer(0);
        Incrementer i2 = new DerivedIncrementer(20);

        i1.Increment(1);
        i1.Increment(2);
        i1.Increment(3);
        i1.Increment(4);
        i1.Increment(5);
        Console.WriteLine("-----------------------------");
        i2.Increment(4);
        i2.Increment(5);
        i2.Increment(6); // will cause an assertion error
    }                    // end Main() method
Esempio n. 2
0
    public static void Main()
    {
        Incrementer i1 = new Incrementer(0);
        Incrementer i2 = new DerivedIncrementer(20);
        Incrementer i3 = new WeakenedDerivedIncrementer(10);
        Incrementer i4 = new StrengthenedDerivedIncrementer(10);

        i1.Increment(1);
        i1.Increment(2);
        i1.Increment(3);
        i1.Increment(4);
        i1.Increment(5);
        Console.WriteLine("-----------------------------");
        i2.Increment(4);
        i2.Increment(5);
        Console.WriteLine("-----------------------------");
        i3.Increment(5);
        Console.WriteLine("-----------------------------");
        i4.Increment(2); // OK so far...
        i4.Increment(3); // OK here too...
        i4.Increment(4); // Wait a minute...this should work!
    }                    // end Main() method
    public static void Main()
    {
        Incrementer i1 = new Incrementer(0);
        Incrementer i2 = new DerivedIncrementer(20);
        Incrementer i3 = new WeakenedDerivedIncrementer(10);

        i1.Increment(1);
        i1.Increment(2);
        i1.Increment(3);
        i1.Increment(4);
        i1.Increment(5);
        Console.WriteLine("-----------------------------");
        i2.Increment(4);
        i2.Increment(5);
        Console.WriteLine("-----------------------------");
        i3.Increment(5);
        i3.Increment(6);  // it does not cause an error here...
        i3.Increment(7);  // nor here
        i3.Increment(8);  // nor here
        i3.Increment(9);  // nor here
        i3.Increment(10); // nor here
        i3.Increment(11); // ...but here it does!
    }                     // end Main() method
    public static void Main()
    {
        Incrementer i1 = new Incrementer(0);

        i1.Increment(1);
        i1.Increment(2);
        i1.Increment(3);
        i1.Increment(4);
        i1.Increment(5);
        i1.Increment(6); // throws an assertion exception
    }                    // end Main() method
    public static void Main()
    {
        Incrementer i1 = new Incrementer(0);

        i1.Increment(1);
        i1.Increment(2);
        i1.Increment(3);
        i1.Increment(4);
        i1.Increment(5);
        i1.Increment(6); // will throw an ArgumentException
    }                    // end Main() method
Esempio n. 6
0
        private static IEnumerable <DirectoryInfo> GetAllBuildStrategiesDirectories(DirectoryInfo directory, HashSet <string> skipList, Incrementer inc, CancellationToken token)
        {
            var container = new { Directory = directory, Depth = 0 };
            var queue     = CreateQueueFromSingle(container);

            queue.Enqueue(container);

            int i = 0;

            while (queue.Count > 0)
            {
                i++;
                if (i % 100 == 0)
                {
                    token.ThrowIfCancellationRequested();
                }

                var current = queue.Dequeue();
                inc.Increment();
                if (ShouldSkipDirectory(current.Directory, current.Depth, skipList))
                {
                    continue;
                }

                if (current.Directory.Name == "BuildStrategies")
                {
                    yield return(current.Directory);
                }


                foreach (DirectoryInfo subdir in current.Directory.EnumerateDirectories("*", SearchOption.TopDirectoryOnly))
                {
                    queue.Enqueue(new { Directory = subdir, Depth = current.Depth + 1 });
                }
            }
        }