private void RemoveProjectFromCache(string name)
{
// Do nothing if the cache hasn't been set up
if (_projectCache == null)
{
return;
}
ProjectName projectName;
_projectCache.TryGetProjectName(name, out projectName);
// Remove the project from the cache
_projectCache.RemoveProject(name);
if (!_projectCache.Contains(DefaultProjectName))
{
DefaultProjectName = null;
}
// for LightSwitch project, the main project is not added to _projectCache, but it is called on removal.
// in that case, projectName is null.
if (projectName != null &&
projectName.CustomUniqueName.Equals(DefaultProjectName, StringComparison.OrdinalIgnoreCase) &&
!_projectCache.IsAmbiguous(projectName.ShortName))
{
DefaultProjectName = projectName.ShortName;
}
}