src/Misc/EFTools/EntityDesign/VisualStudio/VsUtils.cs
// <summary>
//     returns the DirectoryInfo for the root of the project
// </summary>
returns the DirectoryInfo for the root of the project
returns the DirectoryInfo for the root of the project
internal static DirectoryInfo GetProjectRoot(Project project, IServiceProvider serviceProvider)
        {
            DirectoryInfo projectRootDirectoryInfo = null;
            if (IsMiscellaneousProject(project))
            {
                var solution = serviceProvider.GetService(typeof(IVsSolution)) as IVsSolution;
                if (solution != null)
                {
                    string solutionDirectory;
                    string solutionFile;
                    string userOptionsFile;
                    var hr = solution.GetSolutionInfo(out solutionDirectory, out solutionFile, out userOptionsFile);
                    if (NativeMethods.Succeeded(hr) && !String.IsNullOrEmpty(solutionDirectory))
                    {
                        projectRootDirectoryInfo = new DirectoryInfo(solutionDirectory);
                    }
                }
            }
            else
            {
                var projectFullPathProperty = project.Properties.Item("FullPath");
                var value = projectFullPathProperty.Value as string;
                if (!String.IsNullOrEmpty(value))
                {
                    if (IsWebSiteProject(project))
                    {
                        value += Path.DirectorySeparatorChar;
                    }
                    projectRootDirectoryInfo = new DirectoryInfo(value);
                }
            }
            if (projectRootDirectoryInfo == null)
            {
                Debug.Fail("Didn't find a project root for project or solution. Did we miss something?");
                projectRootDirectoryInfo = new DirectoryInfo(".\\");
            }
            return projectRootDirectoryInfo;
        }
internal static DirectoryInfo GetProjectRoot ( Project project , IServiceProvider serviceProvider ) { DirectoryInfo projectRootDirectoryInfo = null ; if ( IsMiscellaneousProject ( project ) ) { var solution = serviceProvider . GetService ( typeof ( IVsSolution ) ) as IVsSolution ; if ( solution != null ) { string solutionDirectory ; string solutionFile ; string userOptionsFile ; var hr = solution . GetSolutionInfo ( out solutionDirectory , out solutionFile , out userOptionsFile ) ; if ( NativeMethods . Succeeded ( hr ) && ! String . IsNullOrEmpty ( solutionDirectory ) ) { projectRootDirectoryInfo = new DirectoryInfo ( solutionDirectory ) ; } } } else { var projectFullPathProperty = project . Properties . Item ( " " ) ; var value = projectFullPathProperty . Value as string ; if ( ! String . IsNullOrEmpty ( value ) ) { if ( IsWebSiteProject ( project ) ) { value += Path . DirectorySeparatorChar ; } projectRootDirectoryInfo = new DirectoryInfo ( value ) ; } } if ( projectRootDirectoryInfo == null ) { Debug . Fail ( " " ) ; projectRootDirectoryInfo = new DirectoryInfo ( " \\ " ) ; } return projectRootDirectoryInfo ; }
returns the DirectoryInfo for the root of the project
returns the DirectoryInfo for the root of the project
// Websites do not have a project filename so the resulting FullPath will not // have a terminating directory separator char. As a result, any downstream // APIs will think that the website name is a filename. // just use the current working direcotry. Not sure that this should ever happen.
project
Project
serviceProvider
IServiceProvider