Umbraco.UmbracoStudio.VisualStudio.ProjectCache.RemoveProject C# (CSharp) Method

RemoveProject() public method

Removes a project and returns the project name instance of the removed project.
public RemoveProject ( string name ) : void
name string name of the project to remove.
return void
        public void RemoveProject(string name)
        {
            ProjectName projectName;
            if (_projectNamesCache.TryGetValue(name, out projectName))
            {
                // Remove from both caches
                RemoveProjectName(projectName);
                RemoveShortName(projectName);
            }
        }

Usage Example

        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;
            }
        }