Пример #1
0
        public BatchWork(
            string root,
            Action <IWork> beforeCallback,
            Action <IWork> afterCallback,
            ID3.Processor.IProcessorMutable operation)
        {
            BeforeCallback = beforeCallback;
            AfterCallback  = afterCallback;
            RootDirectory  = root;

            if (operation.SupportedClasses().Contains(typeof(FileInfo)) ||
                operation.SupportedClasses().Contains(typeof(DirectoryInfo)))
            {
                ID3.Processor.DirectoryProcessor processor = new ID3.Processor.DirectoryProcessor(operation);
                processor.ForceRecurse = true;
                Operation = processor;
            }
            else
            {
                throw new Exception("Operation not supported: " + operation.GetType().Name);
            }
        }
Пример #2
0
        private static void TestIteration()
        {
            string path = VirtualDrive.VirtualFileName(@"TestDirectoryProcessor\TestIteration\");

            IEnumerable <string> files = from counter in Enumerable.Range(0, 2) select Path.Combine(path, "test" + counter + ".bin");

            files.ForEach(n => VirtualDrive.Store(n, new byte[] { }));

            TestProcessor      testProcessor = new TestProcessor(new Type[] { typeof(FileInfo) });
            DirectoryProcessor processor     = new DirectoryProcessor(testProcessor);

            processor.FileMask = "*.bin";

            processor.ProcessMessage(new ProcessorMessageInit());
            processor.Process(new DirectoryInfo(path));

            IEnumerable <string> dstFiles = from item in testProcessor.Objects select item.ToString();

            UnitTest.Test(files.SequenceEqual(dstFiles));

            VirtualDrive.DeleteDirectory(path, true);
        }