Beispiel #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="T:System.Object" /> class.
        /// </summary>
        public FileMonitorViewModel(string filePath, string fileName, string encodingName, bool bufferedRead)
        {
            Preconditions.CheckNotEmptyOrNull(filePath);
            Preconditions.CheckNotEmptyOrNull(fileName);

            _filePath = filePath;
            _fileName = fileName;

            FileExists = File.Exists(filePath);

            try
            {
                //_encoding = Encoding.GetEncoding(encodingName);
                _encoding = Encoding.GetEncoding(51949);
            }
            catch (Exception)
            {
                MessageBox.Show("Could not use encoding " + encodingName + ". Defaulting to UTF8 instead.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            _encoding     = _encoding ?? Encoding.UTF8;
            _encodingName = _encoding.BodyName;

            this._fileMonitor = new TimedFileMonitor(filePath, _encoding)
            {
                BufferedRead = bufferedRead
            };
            this._fileMonitor.FileUpdated += FileMonitorOnFileUpdated;
            this._fileMonitor.FileDeleted += FileMonitorOnFileDeleted;
            this._fileMonitor.FileCreated += FileMonitorOnFileCreated;
            this._fileMonitor.FileRenamed += FileMonitorOnFileRenamed;
        }
Beispiel #2
0
        public static IFileMonitor CreateFolderWatcher()
        {
            LightInject.ServiceContainer _container = new LightInject.ServiceContainer();
            _container.Register(typeof(IFileMonitor), typeof(FileMonitor));
            IFileMonitor obj = _container.GetInstance <IFileMonitor>();

            return(obj);
        }
        public FileEventListener(IFileMonitor fileMonitor, IOnChangeTaskDispatcher taskDispatcher, IGooseActionFactory actionFactory, IFileChangeSubscriber fileChangeSubscriber)
        {
            this.fileMonitor = fileMonitor;
            this.taskDispatcher = taskDispatcher;
            this.actionFactory = actionFactory;

            fileChangeSubscriber.Attach(this);
        }
 public void SetUp()
 {
     _fakeMonitorFactory = Substitute.For <IMonitorFactory>();
     _fakeFileMonitor    = Substitute.For <IFileMonitor>();
     _fakeMonitorFactory.CreateFileMonitor().Returns(_fakeFileMonitor);
     _fakeProjectionFolderCreator   = Substitute.For <IProjectionFolderCreator>();
     _fakeProjectionPipelineFactory = Substitute.For <IProjectionPipelineFactory>();
     _uut = new SubfolderController(_fakeProjectionFolderCreator, _fakeMonitorFactory,
                                    _fakeProjectionPipelineFactory);
 }
Beispiel #5
0
        private void WriteTextAndRaiseEvent(IFileMonitor watchedFolder, string fileName, string source)
        {
            var path      = Path.Combine(this.srcDirectoryInfo.Name, fileName);
            var xmlPath   = Path.Combine(this.srcDirectoryInfo.Name, ".srcml", fileName) + ".xml";
            var eventType = (File.Exists(path) ? FileEventType.FileChanged : FileEventType.FileAdded);

            File.WriteAllText(path, source);

            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(path, eventType));
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(xmlPath, eventType));
        }
Beispiel #6
0
        private void DeleteSourceAndRaiseEvent(IFileMonitor watchedFolder, string fileName)
        {
            var path    = Path.Combine(this.srcDirectoryInfo.Name, fileName);
            var xmlPath = Path.Combine(this.srcDirectoryInfo.Name, ".srcml", fileName);

            xmlPath += ".xml";

            File.Delete(path);
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(path, FileEventType.FileDeleted));
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(xmlPath, FileEventType.FileDeleted));
        }
Beispiel #7
0
        private void RenameSourceFileAndRaiseEvent(IFileMonitor watchedFolder, string oldFileName, string fileName)
        {
            var oldPath = Path.Combine(this.srcDirectoryInfo.Name, oldFileName);
            var path    = Path.Combine(this.srcDirectoryInfo.Name, fileName);

            var oldXmlPath = Path.Combine(this.srcDirectoryInfo.Name, ".srcml", oldFileName) + ".xml";
            var xmlPath    = Path.Combine(this.srcDirectoryInfo.Name, ".srcml", fileName) + ".xml";

            File.Move(oldPath, path);
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(path, oldPath, FileEventType.FileRenamed));
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(oldXmlPath, FileEventType.FileDeleted));
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(xmlPath, FileEventType.FileAdded));
        }
        public bool TryAcquireMonitor(string directoryPath, string filter, bool isContinued, Action<IFileMonitor> fileChangeCallback, WatcherChangeTypes changeTypes, ref IFileMonitor fileMonitor)
        {
            try
            {
                fileMonitor= new FileMonitor(directoryPath, filter, isContinued, fileChangeCallback, changeTypes);

                return true;
            }
            catch
            {
                fileMonitor = null;

                return false;
            }
        }
        public List <Node> Creat(IFileMonitor monitor)
        {
            List <Node> nodes = new List <Node>();

            foreach (var root in monitor.Root)
            {
                root.Monitor = monitor;
                Node root_node = new Node(root.Name)
                {
                    Tag         = root,
                    ContextMenu = _RootMenu,
                    Image       = Resources.AnimationCreateGroup16,
                };

                var categories = from item in root.Children
                                 group item by item.Group into cat
                                 select new { Category = cat.Key, Items = cat.ToArray() };

                foreach (var cat in categories)
                {
                    MonitorItemCollection cat_item = new MonitorItemCollection(cat.Category);
                    cat_item.Monitor = monitor;
                    cat_item.Children.AddRange(cat.Items);

                    Node tn = new Node(cat.Category)
                    {
                        ContextMenu = _GroupMenu,
                        Tag         = cat_item,
                        Image       = Resources.KML_GroundOverlay16
                    };

                    foreach (var item in cat.Items)
                    {
                        Node optn = new Node(item.Name)
                        {
                            ContextMenu = _ItemMenu,
                            Tag         = item,
                            Image       = Resources.ItemInformation16
                        };
                        tn.Nodes.Add(optn);
                    }
                    root_node.Nodes.Add(tn);
                }
                nodes.Add(root_node);
            }
            return(nodes);
        }
Beispiel #10
0
        public void GenerateXmlAndStringForSourceTest()
        {
            IFileMonitor watchedFolder = Substitute.For <IFileMonitor>();

            var archive = new SrcMLArchive(watchedFolder, ".srcml");

            archive.XmlGenerator.ApplicationDirectory = TestConstants.SrcmlPath;
            var xmlDirectory = new DirectoryInfo(archive.ArchivePath);

            File.WriteAllText(SOURCEDIRECTORY + "\\foo.c", String.Format(@"int foo() {{{0}printf(""hello world!"");{0}}}", Environment.NewLine));
            File.WriteAllText(SOURCEDIRECTORY + "\\bar.c", String.Format(@"int bar() {{{0}    printf(""goodbye, world!"");{0}}}", Environment.NewLine));

            string fooXML = archive.GenerateXmlAndStringForSource(SOURCEDIRECTORY + "\\foo.c");
            string barXML = archive.GenerateXmlAndStringForSource(SOURCEDIRECTORY + "\\bar.c");

            Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "2BVUHCFVS6KX3VHC6BBBWFADSZ7EY7FRH48CX7GV627VYYGVEC9WXVFCB8UMWXJSVCGESVDEH4MUXBG4WCJWNM9RKZ9CNJGV6M8C3JFRS2GBXJG4X88LX7RR.xml")));
            Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "2BVUHCFVS6KX3VHC6BBBWFADSZ7EY7FRH48CX7GV627VYYGVEC9WXVFCB8UMWXJSVCGESVDEH4MUXBG4WCJWNM9RKZ9CNJGV6M8C3JFRS2GBXJG4Z4UW37RR.xml")));
        }
Beispiel #11
0
        public void GenerateXmlForSourceTest()
        {
            IFileMonitor watchedFolder = Substitute.For <IFileMonitor>();

            var archive = new SrcMLArchive(watchedFolder, ".srcml");

            archive.XmlGenerator.ApplicationDirectory = TestConstants.SrcmlPath;
            var xmlDirectory = new DirectoryInfo(archive.ArchivePath);

            File.WriteAllText(SOURCEDIRECTORY + "\\foo.c", String.Format(@"int foo() {{{0}printf(""hello world!"");{0}}}", Environment.NewLine));
            File.WriteAllText(SOURCEDIRECTORY + "\\bar.c", String.Format(@"int bar() {{{0}    printf(""goodbye, world!"");{0}}}", Environment.NewLine));

            archive.GenerateXmlForSource(SOURCEDIRECTORY + "\\foo.c");
            archive.GenerateXmlForSource(SOURCEDIRECTORY + "\\bar.c");

            Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "foo.c.xml")));
            Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "bar.c.xml")));
        }
Beispiel #12
0
        private IReconstructionProcessor StartPipeline(IFileMonitor fileMonitor, PermStorageFolderStructure folderStructure)
        {
            BlockingCollection <TempProjectionInfo> queue1 = new BlockingCollection <TempProjectionInfo>();
            BlockingCollection <PermProjectionInfo> queue2 = new BlockingCollection <PermProjectionInfo>();

            var eventHandler = _projectionPipelineFactory.CreateFileMonitorListener(folderStructure, queue1);

            fileMonitor.Created  += eventHandler.OnNewFileDetected;
            fileMonitor.Finished += eventHandler.OnMonitorFinished;

            var copier = _projectionPipelineFactory.CreateProjectionCopier(queue1, queue2, folderStructure);

            TaskWatcher.AddTask(copier.StartCopyingFiles());

            var reconstructionProcessor = _projectionPipelineFactory.CreateReconstructionProcessor(queue2, folderStructure);

            TaskWatcher.AddTask(reconstructionProcessor.StartConsumingProjections());
            return(reconstructionProcessor);
        }
Beispiel #13
0
        public void FileAddDeleteChangeRenameTest()
        {
            int          numberOfEventsRaised = 0;
            IFileMonitor watchedFolder        = Substitute.For <IFileMonitor>();

            var archive = new SrcMLArchive(watchedFolder, ".srcml");

            archive.XmlGenerator.ApplicationDirectory = TestConstants.SrcmlPath;
            var xmlDirectory = new DirectoryInfo(archive.ArchivePath);

            ////archive.SourceFileChanged += (o, e) =>
            archive.SourceFileChanged += (o, e) =>
            {
                numberOfEventsRaised++;
                Assert.That(e.SourceFilePath, Is.Not.SamePathOrUnder(xmlDirectory.Name));
                Console.WriteLine("Event Type '{0}': [{1}]", e.EventType, e.SourceFilePath);
            };

            WriteTextAndRaiseEvent(watchedFolder, "foo.c", @"int foo(int i) {
    return i + 1;
}");
            // Base32 encoded filename foo.c.xml
            Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "2BVUHCFVS6KX3VHC6BBBWFADSZ7EY7FRH48CX7GV627VYYGVEC9WXVFCB8UMWXJSVCGESVDEH4MUXBG4WCJWNM9RKZ9CNJGV6M8C3JFRS2GBXJG4X88LX7RR.xml")));

            WriteTextAndRaiseEvent(watchedFolder, "bar.c", @"int bar(int i) {
    return i - 1;
}");
            // Base32 encoded filename bar.c.xml
            Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "2BVUHCFVS6KX3VHC6BBBWFADSZ7EY7FRH48CX7GV627VYYGVEC9WXVFCB8UMWXJSVCGESVDEH4MUXBG4WCJWNM9RKZ9CNJGV6M8C3JFRS2GBXJG4Z4UW37RR.xml")));

            Directory.CreateDirectory(Path.Combine(SOURCEDIRECTORY, "subdir"));
            WriteTextAndRaiseEvent(watchedFolder, Path.Combine("subdir", "component.c"), @"int are_equal(int i, int j) {
    return i == j;

}");
            // Base32 encoded filename subdir\component.c.xml
            Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "2BVUHCFVS6KX3VHC6BBBWFADSZ7EY7FRH48CX7GV627VYYGVEC9WXVFCB8UMWXJSVCGESVDEH4MUXBG4WCJWNM9RKZ9CNJGV6M8C3JFRS2GBXJG4649WXBSFB27XN7HFT88KNBJFY64XX.xml")));
            Assert.That(archive.FileUnits.Count(), Is.EqualTo(3));
            Assert.That(numberOfFunctions(archive), Is.EqualTo(3));

            DeleteSourceAndRaiseEvent(watchedFolder, "bar.c");
            // Base32 encoded filename bar.c.xml
            Assert.That(!File.Exists(Path.Combine(xmlDirectory.FullName, "2BVUHCFVS6KX3VHC6BBBWFADSZ7EY7FRH48CX7GV627VYYGVEC9WXVFCB8UMWXJSVCGESVDEH4MUXBG4WCJWNM9RKZ9CNJGV6M8C3JFRS2GBXJG4Z4UW37RR.xml")));
            Assert.That(archive.FileUnits.Count(), Is.EqualTo(2));
            Assert.That(numberOfFunctions(archive), Is.EqualTo(2));

            WriteTextAndRaiseEvent(watchedFolder, Path.Combine("subdir", "component.c"), @"struct A {
    int a;
    char b;
}");
            // Base32 encoded filename subdir\component.c.xml
            Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "2BVUHCFVS6KX3VHC6BBBWFADSZ7EY7FRH48CX7GV627VYYGVEC9WXVFCB8UMWXJSVCGESVDEH4MUXBG4WCJWNM9RKZ9CNJGV6M8C3JFRS2GBXJG4649WXBSFB27XN7HFT88KNBJFY64XX.xml")));
            Assert.That(archive.FileUnits.Count(), Is.EqualTo(2));
            Assert.That(numberOfFunctions(archive), Is.EqualTo(1));

            RenameSourceFileAndRaiseEvent(watchedFolder, "foo.c", "foo2.c");
            // Base32 encoded filename foo.c.xml
            Assert.That(!File.Exists(Path.Combine(xmlDirectory.FullName, "2BVUHCFVS6KX3VHC6BBBWFADSZ7EY7FRH48CX7GV627VYYGVEC9WXVFCB8UMWXJSVCGESVDEH4MUXBG4WCJWNM9RKZ9CNJGV6M8C3JFRS2GBXJG4X88LX7RR.xml")));
            // Base32 encoded filename foo2.c.xml
            Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "2BVUHCFVS6KX3VHC6BBBWFADSZ7EY7FRH48CX7GV627VYYGVEC9WXVFCB8UMWXJSVCGESVDEH4MUXBG4WCJWNM9RKZ9CNJGV6M8C3JFRS2GBXJG4X88LXJUS22.xml")));
            Assert.That(archive.FileUnits.Count(), Is.EqualTo(2));
            Assert.That(numberOfFunctions(archive), Is.EqualTo(1));

            Assert.That(numberOfEventsRaised, Is.EqualTo(6));
        }
Beispiel #14
0
 private void _fileMonitor_FileUpdated(IFileMonitor fm, string content)
 {
     this.Invoke(new Action <string>(UpdateBandwidthLog), content);
     Log.Info(content);
 }
 private void FileMonitorOnFileDeleted(IFileMonitor obj)
 {
     OnUpdated();
     FileExists = false;
 }
 private void FileMonitorOnFileUpdated(IFileMonitor fileMonitor, string contents)
 {
     OnUpdated();
     Contents += contents;
 }
Beispiel #17
0
        public static bool TryAcquireMonitor(this IFileMonitorManager col, string path, Action <IFileMonitor> fileChangeCallback)
        {
            IFileMonitor fileMonitor = null;

            return(col.TryAcquireMonitor(Path.GetDirectoryName(path), Path.GetFileName(path), true, fileChangeCallback, WatcherChangeTypes.All, ref fileMonitor));
        }
Beispiel #18
0
        public static bool TryAcquireMonitor(this IFileMonitorManager col, string directoryPath, string filter, Action <IFileMonitor> fileChangeCallback)
        {
            IFileMonitor fileMonitor = null;

            return(col.TryAcquireMonitor(directoryPath, filter, true, fileChangeCallback, WatcherChangeTypes.All, ref fileMonitor));
        }
            public TestSubscriptionBuilder(IFileMonitor fileMonitor, FileEventListener changeConsumer, IGooseActionFactory actionFactory)
            {
                this.fileMonitor = fileMonitor;
                this.changeConsumer = changeConsumer;
                this.actionFactory = actionFactory;

                A.CallTo(() => this.actionFactory.Create(A<ActionConfiguration>._, A<IEnumerable<string>>._))
                    .WithAnyArguments()
                    .ReturnsLazily(call => ((IEnumerable<string>)call.Arguments[1]).Select(_ => A.Fake<IGooseAction>()));
            }
Beispiel #20
0
        public void GenerateXmlForDirectoryTest()
        {
            IFileMonitor watchedFolder = Substitute.For <IFileMonitor>();

            var archive = new SrcMLArchive(watchedFolder, ".srcml");

            archive.XmlGenerator.ApplicationDirectory = TestConstants.SrcmlPath;
            var xmlDirectory = new DirectoryInfo(archive.ArchivePath);

            File.WriteAllText(SOURCEDIRECTORY + "\\foo.c", String.Format(@"int foo() {{{0}printf(""hello world!"");{0}}}", Environment.NewLine));
            File.WriteAllText(SOURCEDIRECTORY + "\\bar.c", String.Format(@"int bar() {{{0}    printf(""goodbye, world!"");{0}}}", Environment.NewLine));
            Directory.CreateDirectory(Path.Combine(SOURCEDIRECTORY, "subdir1"));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir1\\foo1.c", String.Format(@"int foo1() {{{0}printf(""hello world 1!"");{0}}}", Environment.NewLine));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir1\\bar1.c", String.Format(@"int bar1() {{{0}    printf(""goodbye, world 1!"");{0}}}", Environment.NewLine));
            Directory.CreateDirectory(Path.Combine(SOURCEDIRECTORY, "subdir2"));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir2\\foo2.c", String.Format(@"int foo2() {{{0}printf(""hello world 2!"");{0}}}", Environment.NewLine));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir2\\bar2.c", String.Format(@"int bar2() {{{0}    printf(""goodbye, world 2!"");{0}}}", Environment.NewLine));
            Directory.CreateDirectory(Path.Combine(SOURCEDIRECTORY, "subdir1\\subdir11"));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir1\\subdir11\\foo11.c", String.Format(@"int foo11() {{{0}printf(""hello world 11!"");{0}}}", Environment.NewLine));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir1\\subdir11\\bar11.c", String.Format(@"int bar11() {{{0}    printf(""goodbye, world 11!"");{0}}}", Environment.NewLine));
            Directory.CreateDirectory(Path.Combine(SOURCEDIRECTORY, "subdir1\\subdir12"));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir1\\subdir12\\foo12.c", String.Format(@"int foo12() {{{0}printf(""hello world 12!"");{0}}}", Environment.NewLine));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir1\\subdir12\\bar12.c", String.Format(@"int bar12() {{{0}    printf(""goodbye, world 12!"");{0}}}", Environment.NewLine));
            Directory.CreateDirectory(Path.Combine(SOURCEDIRECTORY, "subdir2\\subdir21"));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir2\\subdir21\\foo21.c", String.Format(@"int foo21() {{{0}printf(""hello world 21!"");{0}}}", Environment.NewLine));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir2\\subdir21\\bar21.c", String.Format(@"int bar21() {{{0}    printf(""goodbye, world 21!"");{0}}}", Environment.NewLine));
            Directory.CreateDirectory(Path.Combine(SOURCEDIRECTORY, "subdir2\\subdir22"));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir2\\subdir22\\foo22.c", String.Format(@"int foo22() {{{0}printf(""hello world 22!"");{0}}}", Environment.NewLine));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir2\\subdir22\\bar22.c", String.Format(@"int bar22() {{{0}    printf(""goodbye, world 22!"");{0}}}", Environment.NewLine));

            System.Threading.Thread.Sleep(5000);
            ////archive.GenerateXmlForDirectory(SOURCEDIRECTORY);

            /*
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "foo.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "bar.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\foo1.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\bar1.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\foo2.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\bar2.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\subdir11\\foo11.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\subdir11\\bar11.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\subdir12\\foo12.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\subdir12\\bar12.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\subdir21\\foo21.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\subdir21\\bar21.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\subdir22\\foo22.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\subdir22\\bar22.c.xml")));
             * Assert.That(archive.FileUnits.Count(), Is.EqualTo(14));
             */

            File.WriteAllText(SOURCEDIRECTORY + "\\foo.c", String.Format(@"int foo() {{{0}printf(""hello world! changed"");{0}}}", Environment.NewLine));
            File.WriteAllText(SOURCEDIRECTORY + "\\subdir2\\subdir21\\bar21.c", String.Format(@"int bar21() {{{0}    printf(""goodbye, world 21! changed"");{0}}}", Environment.NewLine));
            File.Delete("C:\\Users\\USJIZHE\\Documents\\GitHub\\SrcML.NET\\Build\\Debug\\testSourceDir\\subdir1\\subdir12\\bar12.c");
            File.Move("C:\\Users\\USJIZHE\\Documents\\GitHub\\SrcML.NET\\Build\\Debug\\testSourceDir\\subdir1\\subdir11\\foo11.c",
                      "C:\\Users\\USJIZHE\\Documents\\GitHub\\SrcML.NET\\Build\\Debug\\testSourceDir\\subdir1\\subdir11\\foo1111111.c");

            System.Threading.Thread.Sleep(5000);
            ////archive.GenerateXmlForDirectory(SOURCEDIRECTORY);

            /*
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "foo.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "bar.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\foo1.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\bar1.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\foo2.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\bar2.c.xml")));
             * Assert.That(!File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\subdir11\\foo11.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\subdir11\\foo1111111.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\subdir11\\bar11.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\subdir12\\foo12.c.xml")));
             * Assert.That(!File.Exists(Path.Combine(xmlDirectory.FullName, "subdir1\\subdir12\\bar12.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\subdir21\\foo21.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\subdir21\\bar21.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\subdir22\\foo22.c.xml")));
             * Assert.That(File.Exists(Path.Combine(xmlDirectory.FullName, "subdir2\\subdir22\\bar22.c.xml")));
             * Assert.That(archive.FileUnits.Count(), Is.EqualTo(13));
             */
        }
 private void FileMonitorOnFileCreated(IFileMonitor obj)
 {
     OnUpdated();
     FileExists = true;
 }
 private void FileMonitorOnFileDeleted(IFileMonitor obj)
 {
     OnUpdated();
     FileExists = false;
 }
 private void FileMonitorOnFileRenamed(IFileMonitor fileMonitor, string newPath)
 {
     FilePath = newPath;
     OnRenamed();
 }
 private void FileMonitorOnFileRenamed(IFileMonitor fileMonitor, string newPath)
 {
     FilePath = newPath;
     OnRenamed();
 }
 private void FileMonitorOnFileCreated(IFileMonitor obj)
 {
     OnUpdated();
     FileExists = true;
 }
        private void WriteTextAndRaiseEvent(IFileMonitor watchedFolder, string fileName, string source)
        {
            var path = Path.Combine(this.srcDirectoryInfo.Name, fileName);
            var xmlPath = Path.Combine(this.srcDirectoryInfo.Name, ".srcml", fileName) + ".xml";
            var eventType = (File.Exists(path) ? FileEventType.FileChanged : FileEventType.FileAdded);

            File.WriteAllText(path, source);

            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(path, eventType));
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(xmlPath, eventType));
        }
 private void FileMonitorOnFileUpdated(IFileMonitor fileMonitor, string contents)
 {
     OnUpdated();
     Contents += contents;
 }
        private void DeleteSourceAndRaiseEvent(IFileMonitor watchedFolder, string fileName)
        {
            var path = Path.Combine(this.srcDirectoryInfo.Name, fileName);
            var xmlPath = Path.Combine(this.srcDirectoryInfo.Name, ".srcml", fileName);
            xmlPath += ".xml";

            File.Delete(path);
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(path, FileEventType.FileDeleted));
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(xmlPath, FileEventType.FileDeleted));
        }
 public FileMonitorFinishedArgs(IFileMonitor monitor)
 {
     Monitor = monitor;
 }
        private void RenameSourceFileAndRaiseEvent(IFileMonitor watchedFolder, string oldFileName, string fileName)
        {
            var oldPath = Path.Combine(this.srcDirectoryInfo.Name, oldFileName);
            var path = Path.Combine(this.srcDirectoryInfo.Name, fileName);

            var oldXmlPath = Path.Combine(this.srcDirectoryInfo.Name, ".srcml", oldFileName) + ".xml";
            var xmlPath = Path.Combine(this.srcDirectoryInfo.Name, ".srcml", fileName) + ".xml";

            File.Move(oldPath, path);
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(path, oldPath, FileEventType.FileRenamed));
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(oldXmlPath, FileEventType.FileDeleted));
            watchedFolder.FileEventRaised += Raise.EventWith(new FileEventRaisedArgs(xmlPath, FileEventType.FileAdded));
        }
        public bool TryAcquireMonitor(string directoryPath, string filter, bool isContinued, Action <IFileMonitor> fileChangeCallback, WatcherChangeTypes changeTypes, ref IFileMonitor fileMonitor)
        {
            try
            {
                fileMonitor = new FileMonitor(directoryPath, filter, isContinued, fileChangeCallback, changeTypes);

                return(true);
            }
            catch
            {
                fileMonitor = null;

                return(false);
            }
        }
Beispiel #32
0
 public Program(IServiceProvider services, IApplicationEnvironment environment, IFileMonitor fileMonitor)
 {
     _services    = services;
     _environment = environment;
     _fileMonitor = fileMonitor;
 }