コード例 #1
0
        static void Main(string[] args)
        {
            var pump         = new FileDataSource(new StreamReader(@"data\TestData.txt"));
            var shifter      = new CircularShifter();
            var alphabetizer = new Alphabetizer();

            #region Modifying the requirement - add a 'noise' list to remove words from the index

            //var noiseWords = new FileDataSource(new StreamReader(@"data\noise.txt")).Begin();
            //var noiseRemover = new NoiseRemoval(noiseWords);
            //pump.Successor = noiseRemover;
            //noiseRemover.Successor = shifter;

            #endregion

            pump.Successor    = shifter;
            shifter.Successor = alphabetizer;

            var pipeline = new Pipeline <string>(pump: pump, sink: new ConsoleWriter());
            Console.WriteLine("Begin Execution At:{0}", DateTime.UtcNow);
            pipeline.Execute();
            Console.WriteLine("Stop Execution At:{0}", DateTime.UtcNow);

            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: mallickhruday/Styles
        static void Main(string[] args)
        {
            const int bufferSize             = 32;
            var       rawDataBuffer          = new BlockingCollection <string>(bufferSize);
            var       shiftedDataBuffer      = new BlockingCollection <string>(bufferSize);
            var       alphabetizedDataBuffer = new BlockingCollection <string>(bufferSize);

            var pump = new FileDataSource(rawDataBuffer, new StreamReader(@"data\TestData.txt"));

            var shifter      = new CircularShifter(rawDataBuffer, shiftedDataBuffer);
            var alphabetizer = new Alphabetizer(shiftedDataBuffer, alphabetizedDataBuffer);
            var writer       = new ConsoleWriter(alphabetizedDataBuffer);

            var pipeline = new Pipeline <string>(pump: pump, sink: writer, filters: new List <IAmAFilter <string> > {
                shifter, alphabetizer
            });

            Console.WriteLine("Begin Execution At:{0}", DateTime.UtcNow);
            pipeline.Execute();
            Console.WriteLine("Stop Execution At:{0}", DateTime.UtcNow);

            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }