SIL.FieldWorks.FieldWorks.RenameProject C# (CSharp) Méthode

RenameProject() static private méthode

Rename the database.
static private RenameProject ( string dbNewName, FwApp app ) : bool
dbNewName string new basename desired
app SIL.FieldWorks.Common.Framework.FwApp The calling application
Résultat bool
		internal static bool RenameProject(string dbNewName, FwApp app)
		{
			Debug.Assert(s_cache.ProjectId.IsLocal);

			// ENHANCE (FWR-722): If this is a shared database, warn the user that other clients
			// might hate them if they rename this project.
			// TODO (FWR-722): Also move project-specific registry settings

			string appName = app.ApplicationName;
			ProjectId projId = s_projectId;

			s_doingRename = true;
			s_renameSuccessful = false;
			s_renameNewName = dbNewName;
			try
			{
				// Although this code looks strange, the rename actually takes place after the
				// saving of the data (see CommitAndDisposeCache). The reason for this is that
				// closing all of the main windows causes the cache to be disposed (or will
				// during the next Windows message pump). We needed to have the rename happen
				// after all the main windows are closed, but before the cache is disposed.
				// The only semi-clean way of doing that is to do what we did. (FWR-3179)
				ExecuteWithAppsShutDown(GetCommandLineAbbrevForAppName(app.ApplicationName),
					() => s_projectId ?? projId);
			}
			finally
			{
				s_doingRename = false;
				s_renameNewName = null;
			}

			if (s_renameSuccessful)
			{
				FwApp newApp = GetAppFromAppNameOrAbbrev(appName);
				newApp.RegistrySettings.LatestProject = projId.Handle;
				newApp.RegistrySettings.LatestServer = projId.ServerName ?? string.Empty;
			}
			return s_renameSuccessful;
		}
FieldWorks