public Db4oProjectSetupForTesting(string xmlOfEntries)
		{
			_projectDirectory = new ProjectDirectorySetupForTesting(xmlOfEntries);

			_project = new WeSayWordsProject();
			_project.LoadFromLiftLexiconPath(_projectDirectory.PathToLiftFile);
			//CacheBuilder cacheBuilder = new CacheBuilder(_projectDirectory.PathToLiftFile);
			//cacheBuilder.DoWork(new NullProgressState());

			_lexEntryRepository = new LexEntryRepository(_project.PathToRepository);
			// InMemoryRecordListManager();
		}
		public void Setup()
		{
			string entriesXml =
					@"<entry id='foo1'><lexical-unit><form lang='v'><text>fooOne</text></form></lexical-unit></entry>
								<entry id='foo2'><lexical-unit><form lang='v'><text>fooTwo</text></form></lexical-unit></entry>
								<entry id='foo3'><lexical-unit><form lang='v'><text>fooThree</text></form></lexical-unit></entry>";
			_projectDirectory = new ProjectDirectorySetupForTesting(entriesXml);

			_project = new WeSayWordsProject();
			_project.LoadFromLiftLexiconPath(_projectDirectory.PathToLiftFile);
			_tabbedForm = new TabbedForm();
			_project.Tasks = new List<ITask>();
			_dashboardTask = new MockTask("Dashboard", "The control center.", true);
			_project.Tasks.Add(_dashboardTask);
			_dictionaryTask = new MockTask("Dictionary blah blah", "The whole lexicon.", true);
			_project.Tasks.Add(_dictionaryTask);

			_tabbedForm.InitializeTasks(_project.Tasks);
		}
示例#3
0
文件: WeSayApp.cs 项目: bbriggs/wesay
		//private static LiftUpdateService SetupUpdateService(LexEntryRepository lexEntryRepository)
		//{
		//    LiftUpdateService liftUpdateService;
		//    liftUpdateService = new LiftUpdateService(lexEntryRepository);
		//    return liftUpdateService;
		//}

		private static WeSayWordsProject InitializeProject(string liftPath)
		{
			WeSayWordsProject project = new WeSayWordsProject();
			liftPath = DetermineActualLiftPath(liftPath);
			if (liftPath == null)
			{
				ErrorReport.ReportNonFatalMessage(
						"WeSay was unable to figure out what lexicon to work on. Try opening the LIFT file by double clicking on it. If you don't have one yet, run the WeSay Configuration Tool to make a new WeSay project.");
				return null;
			}

			liftPath = project.UpdateFileStructure(liftPath);

			if (project.LoadFromLiftLexiconPath(liftPath))
			{
				Settings.Default.PreviousLiftPath = liftPath;
			}
			else
			{
				return null;
			}

			try
			{
				project.MigrateConfigurationXmlIfNeeded();
			}
			catch
			{
				ErrorReport.ReportNonFatalMessage(
						"WeSay was unable to migrate the WeSay configuration file for the new version of WeSay. This may cause WeSay to not function properly. Try opening the project in the WeSay Configuration Tool to fix this.");
			}

			return project;
		}
示例#4
0
		public void OpenProject(string path)
		{
			//System.Configuration.ConfigurationManager.AppSettings["LastConfigFilePath"] = path;

			//strip off any trailing '\'
			if (path[path.Length - 1] == Path.DirectorySeparatorChar ||
				path[path.Length - 1] == Path.AltDirectorySeparatorChar)
			{
				path = path.Substring(0, path.Length - 1);
			}

			try
			{
				Project = new WeSayWordsProject();

				//just open the accompanying lift file.
				path = path.Replace(".WeSayConfig", ".lift");

				if (path.Contains(".lift"))
				{
					path = Project.UpdateFileStructure(path);
					if (!Project.LoadFromLiftLexiconPath(path))
					{
						Project = null;
						return;
					}
				}
						//                else if (path.Contains(".WeSayConfig"))
						//                {
						//                    this.Project.LoadFromConfigFilePath(path);
						//                }
				else if (Directory.Exists(path))
				{
					Project.LoadFromProjectDirectoryPath(path);
				}
				else
				{
					throw new ApplicationException(path +
												   " is not named as a .lift file or .WeSayConfig file.");
				}
			}
			catch (Exception e)
			{
				ErrorReport.ReportNonFatalMessage("WeSay was not able to open that project. \r\n" +
												  e.Message);
				return;
			}

			IContainer container = _project.Container.CreateInnerContainer();
			var containerBuilder = new Autofac.Builder.ContainerBuilder();
			containerBuilder.Register(typeof(Tasks.TaskListView));
			containerBuilder.Register(typeof(Tasks.TaskListPresentationModel));
			containerBuilder.Build(container);

			SetupProjectControls(container);

			if (Project != null)
			{
				Settings.Default.MruConfigFilePaths.AddNewPath(Project.PathToConfigFile);
			}
		}