示例#1
0
        public void TextViewCreated(IWpfTextView textView)
        {
            ITextDocument textDoc;
            //string fileName = null;
            var rc = textView.TextBuffer.Properties.TryGetProperty <ITextDocument>(typeof(ITextDocument), out textDoc);

            if (rc)
            {
                //fileName = Path.GetFileName(textDoc.FilePath);
                string            fileFullName   = System.IO.Path.GetFullPath(textDoc.FilePath).ToLower();
                IFileTracker      fileTracker    = cpTrackServ.GetFileTracker(fileFullName);
                FileChangeTracker fChangeTracker = GetFChangeTracker(fileFullName);
                if (fChangeTracker == null)
                {
                    if (fileTracker != null)
                    {
                        fChangeTracker = new FileChangeTracker(textView, fileFullName, fileTracker);
                        fileTrackers.Add(fChangeTracker);
                    }
                    else
                    {
                        AddView(fileFullName, textView);
                    }
                }
                else
                {
                    fChangeTracker.Advise(textView);
                }
            }
        }
示例#2
0
        private _FileSystemImportContext(PathString path, IFileTracker tc)
        {
            System.Diagnostics.Debug.Assert(path.IsValidAbsoluteFilePath);

            _SourcePath  = path;
            _FileTracker = tc;
        }
        void OnFileCPsCreated(IConstructEventArgs <IFileChartPoints> args)
        {
            IFileTracker  fTracker    = AddFileTracker(args.obj.data.fileFullName);
            ICPEntTracker cpValidator = new FileCPTracker(args.obj);

            fTracker.Add(cpValidator);
            addFTrackerEvent.Fire(new FileTrackerArgs(fTracker));
        }
示例#4
0
        public static _FileSystemImportContext Create(PathString path, IFileTracker tc)
        {
            if (!path.IsValidAbsoluteFilePath)
            {
                throw new ArgumentException(nameof(path));
            }

            return(new _FileSystemImportContext(path, tc));
        }
示例#5
0
        public FileManager(IConfig config, IFileTracker fileTracker)
        {
            _storagePath = config.StoragePath;
            _fileTracker = fileTracker;

            if (!Directory.Exists(_storagePath))
            {
                Directory.CreateDirectory(_storagePath);
            }
        }
示例#6
0
        public void Setup()
        {
            _mockConfig = new Mock <IConfig>();
            _mockConfig.SetupGet(c => c.StoragePath).Returns(@"./test_storage/");
            _mockConfig.SetupGet(c => c.StorageFile).Returns(@"./test_storage.json");
            _mockConfig.SetupGet(c => c.StorageTimeout).Returns(-1);

            _mockDateTimeProvider = new Mock <IDateTimeProvider>();
            _mockDateTimeProvider.Setup(d => d.GetDateTime()).Returns(new System.DateTime(2019, 8, 1, 12, 0, 0));

            _fileTracker = new FileTracker(_mockConfig.Object, _mockDateTimeProvider.Object);
        }
        protected IFileTracker AddFileTracker(string fileFullName)
        {
            IFileTracker fTracker = GetFileTracker(fileFullName);

            if (fTracker == null)
            {
                fTracker = new FileTracker(fileFullName);
                fTracker.emptyFTrackerEvent += OnEmptyCpEvent;
                filesTrackers.Add(fTracker);
            }

            return(fTracker);
        }
        private bool RemoveFileTracker(string fileFullName)
        {
            IFileTracker fTracker = GetFileTracker(fileFullName);

            if (fTracker != null)
            {
                filesTrackers.Remove(fTracker);
                remFTrackerEvent.Fire(new FileTrackerArgs(fTracker));

                return(true);
            }

            return(false);
        }
示例#9
0
        public static IEnumerable <_FileSystemImportContext> CreateBatch(PathString dir, string fileMask, bool allDirectories, Func <PathString, bool> pathValidator, IFileTracker tc)
        {
            var files = System.IO.Directory.GetFiles(dir, fileMask, allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);

            foreach (var f in files)
            {
                var fp = new PathString(f);

                if (!pathValidator(fp))
                {
                    continue;
                }

                yield return(Create(fp, tc));
            }
        }
示例#10
0
        //private IFileChartPoints fPnts;

        public FileChangeTracker(IWpfTextView _textView, string _fileFullName, IFileTracker _fileTracker)
        {
            fileFullName = _fileFullName;
            fileTracker  = _fileTracker;
            Advise(_textView);
        }
示例#11
0
        protected _FileSystemExportContext(PathString path, PathString o, IFileTracker tc) : base(path, tc)
        {
            System.Diagnostics.Debug.Assert(path.IsValidAbsoluteFilePath);

            _OutDir = o;
        }
示例#12
0
 private _SimulateExportContext(PathString p, Action <string, Byte[]> fileCreationNotifier, IFileTracker tc) : base(p, tc)
 {
     _FileCreationNotifier = fileCreationNotifier;
 }
示例#13
0
        public static _SimulateExportContext Create(PathString path, Action <string, Byte[]> fileCreationNotifier, IFileTracker tc)
        {
            // TODO: ensure path is within the specified target path

            return(new _SimulateExportContext(path, fileCreationNotifier, tc));
        }
示例#14
0
 protected _ExportContextBase(PathString targetPath, IFileTracker tc)
 {
     _TargetPath  = targetPath;
     _FileTracker = tc;
 }
示例#15
0
 public FileTrackerArgs(IFileTracker _fileTracker)
 {
     fileTracker = _fileTracker;
 }