示例#1
0
        public ProjectInfo(string name,
                           string pathToApplicationRootDirectory,
                           string pathToTopLevelDirectory,
                           string pathToLIFT,
                           string pathToExportDirectory,
                           string[] filesBelongingToProject,
                           FileLocater locateFile,
                           IWritingSystemRepository writingSystems,
                           IServiceProvider serviceProvider,
                           // these signatures were to reduce the dependencies on addins that didn't need this stuff
                           object project)
        // these signatures were to reduce the dependencies on addins that didn't need this stuff

        {
            ServiceProvider          = serviceProvider;
            _pathToTopLevelDirectory = pathToTopLevelDirectory;
            _locateFile              = locateFile;
            _writingSystems          = writingSystems;
            _project                 = project;
            _filesBelongingToProject = filesBelongingToProject;
            _name = name;
            _pathToApplicationRootDirectory = pathToApplicationRootDirectory;
            _pathToLIFT            = pathToLIFT;
            _pathToExportDirectory = pathToExportDirectory;
        }
示例#2
0
		public ProjectInfo(string name,
						   string pathToApplicationRootDirectory,
						   string pathToTopLevelDirectory,
						   string pathToLIFT,
						   string pathToExportDirectory,
						   string[] filesBelongingToProject,
						   FileLocater locateFile,
						   WritingSystemCollection writingSystems,
						   IServiceProvider serviceProvider,
						   // these signatures were to reduce the dependencies on addins that didn't need this stuff
						   object project)
				// these signatures were to reduce the dependencies on addins that didn't need this stuff

		{
			ServiceProvider = serviceProvider;
			_pathToTopLevelDirectory = pathToTopLevelDirectory;
			_locateFile = locateFile;
			_writingSystems = writingSystems;
			_project = project;
			_filesBelongingToProject = filesBelongingToProject;
			_name = name;
			_pathToApplicationRootDirectory = pathToApplicationRootDirectory;
			_pathToLIFT = pathToLIFT;
			_pathToExportDirectory = pathToExportDirectory;
		}
示例#3
0
文件: AddinSet.cs 项目: bbriggs/wesay
		public static AddinSet Create(AddinSettingsGetter getSettingsNodesFromConfiguration,
									  FileLocater locateFile)
		{
			_singleton = new AddinSet(getSettingsNodesFromConfiguration, locateFile);

			return _singleton;
		}
示例#4
0
        public static AddinSet Create(AddinSettingsGetter getSettingsNodesFromConfiguration,
                                      FileLocater locateFile)
        {
            _singleton = new AddinSet(getSettingsNodesFromConfiguration, locateFile);

            return(_singleton);
        }
示例#5
0
文件: AddinSet.cs 项目: bbriggs/wesay
		private AddinSet(AddinSettingsGetter getSettingsNodesFromConfiguration,
						 FileLocater locateFile)
		{
			_locateFile = locateFile;
			_getSettingsNodesFromConfiguration = getSettingsNodesFromConfiguration;
		}
示例#6
0
 private AddinSet(AddinSettingsGetter getSettingsNodesFromConfiguration,
                  FileLocater locateFile)
 {
     _locateFile = locateFile;
     _getSettingsNodesFromConfiguration = getSettingsNodesFromConfiguration;
 }
示例#7
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            ScannerArgument arg = e.Argument as ScannerArgument;
            ScannerTracer tracer = arg.Tracer;
            tracer.Progress.Existing = arg.ExistingFiles.Length;
            tracer.State = ScannerState.Scanning;
            if (worker.WorkerReportsProgress)
                worker.ReportProgress(0, new ScanProgressChangedEventArgs(tracer));

            List<FileInfo> addFiles = GetFilesFromDir(arg);
            List<FileInfo> updateFiles = new List<FileInfo>();
            List<FileInfo> removeFiles = new List<FileInfo>(arg.ExistingFiles.Length);
            foreach (RawTrack rt in arg.ExistingFiles)
                removeFiles.Add(new FileInfo(rt.FullFilename));

            if (arg.IgnoredFiles.Length > 0)
            {
                for (int i = 0; i < arg.IgnoredFiles.Length; i++)
                {
                    FileInfo file = new FileInfo(arg.IgnoredFiles[i]);
                    FileLocater fl = new FileLocater(file);
                    int a = addFiles.RemoveAll(fl.Match);
                    int r = removeFiles.RemoveAll(fl.Match);
                }
            }

            addFiles.Sort(ComparePath);

            if (removeFiles.Count > 0)
            {
                int t = 0; //removeFiles index
                for (int i = 0; i < addFiles.Count; i++)
                {
                    int comp = ComparePath(addFiles[i], removeFiles[t]);
                    while (comp > 0)
                    {
                        t++;
                        if (t >= removeFiles.Count)
                            break;
                        comp = ComparePath(addFiles[i], removeFiles[t]);
                    }

                    if (comp == 0)
                    {
                        updateFiles.Add(addFiles[i]);
                        addFiles.RemoveAt(i);
                        removeFiles.RemoveAt(t);
                        i--;
                    }

                    if (t >= removeFiles.Count)
                        break;

                    if (removeFiles.Count == 0)
                        break;
                }
            }

            if (!arg.RemoveDeadFiles)
                removeFiles.Clear();

            if (removeFiles.Count > 0)
                foreach (FileInfo file in removeFiles)
                    existingFiles.Remove(file.FullName);

            //Scanning complete, setting values of tracer.Progress
            //Setting how many files were removed from existingFiles (if any)
            tracer.Progress.Removed = removeFiles.Count;

            if (arg.ParseAdd)
                tracer.Progress.AddTotal = addFiles.Count;
            else
                tracer.Progress.AddTotal = 0;

            if (arg.ParseUpdate)
                tracer.Progress.UpdateTotal = updateFiles.Count;
            else
                tracer.Progress.UpdateTotal = 0;

            //Change scanner state and report progress
            tracer.State = ScannerState.Parsing;
            if (worker.WorkerReportsProgress)
                worker.ReportProgress(0, new ScanProgressChangedEventArgs(tracer));

            List<FileInfo> errorFiles = new List<FileInfo>();
            List<RawTrack> addData = new List<RawTrack>(addFiles.Count);
            List<RawTrack> updateData = new List<RawTrack>(updateFiles.Count);

            if (arg.ParseUpdate)
                for (int i = 0; i < updateFiles.Count; i++)
                {
                    RawTrack rt;
                    if (parser.TryParseTrack(updateFiles[i].FullName, out rt))
                    {
                        updateData.Add(rt);
                        tracer.Progress.Updated++;
                    }
                    else
                    {
                        errorFiles.Add(updateFiles[i]);
                        tracer.Progress.UpdateError++;
                    }
                    if (worker.WorkerReportsProgress)
                        worker.ReportProgress(0, new ScanProgressChangedEventArgs(tracer));
                }

            if (arg.ParseAdd)
                for (int i = 0; i < addFiles.Count; i++)
                {
                    RawTrack rt;
                    if (parser.TryParseTrack(addFiles[i].FullName, out rt))
                    {
                        addData.Add(rt);
                        existingFiles.Add(rt);
                        tracer.Progress.Added++;
                    }
                    else
                    {
                        errorFiles.Add(addFiles[i]);
                        tracer.Progress.AddError++;
                    }
                    if (worker.WorkerReportsProgress)
                        worker.ReportProgress(0, new ScanProgressChangedEventArgs(tracer));
                }

            e.Result = new ScanCompletedEventArgs(removeFiles, errorFiles, addData, updateData, arg.ExistingFiles);

            tracer.State = ScannerState.Completed;

            if (worker.WorkerReportsProgress)
                worker.ReportProgress(0, new ScanProgressChangedEventArgs(tracer));

            isrunning = false;
        }