private static List <KeyValuePair <IvyModule, string> > GetIvyModules(Project project)
        {
            var ivyModules = new List <KeyValuePair <IvyModule, string> >();

            var projectDirectory   = new DirectoryInfo(Path.GetDirectoryName(project.FullName));
            var workspaceDirectory = new DirectoryInfo(
                (!string.IsNullOrEmpty(Options.Instance.WorkspacePath)
                ? Options.Instance.WorkspacePath
                : projectDirectory.Parent.FullName));

            if (!workspaceDirectory.Exists)
            {
                Output.Instance.WriteLine("The specified workspace directory doesn't exist, can't continue looking for ivy.xml files");
                return(ivyModules);
            }

            FileInfo[] ivyFiles = workspaceDirectory.GetFiles("ivy.xml", SearchOption.AllDirectories);

            foreach (FileInfo ivyFile in ivyFiles)
            {
                IvyModule ivyModule = XmlFileSerializer <IvyModule> .Deserialize(ivyFile.FullName);

                ivyModules.Add(new KeyValuePair <IvyModule, string>(ivyModule, ivyFile.FullName));
            }

            return(ivyModules);
        }
Example #2
0
        public void Load()
        {
            DTE2 dte = Globals.DTE;

            if (!dte.HasSolution())
            {
                return;
            }

            Solution4 solution = dte.Solution as Solution4;

            var solutionDirectory = new DirectoryInfo(Path.GetDirectoryName(solution.FullName));

            var parentSettingsFile = new FileInfo(
                solutionDirectory.Parent.FullName +
                Path.DirectorySeparatorChar +
                "default.ivyvisual");

            FileInfo settingsFileToDeserialize = null;

            if (parentSettingsFile.Exists)
            {
                settingsFileToDeserialize = parentSettingsFile;
            }
            else
            {
                var settingsFile = new FileInfo(solution.FullName + ".ivyvisual");

                if (settingsFile.Exists)
                {
                    settingsFileToDeserialize = settingsFile;
                }
                else
                {
                    return;
                }
            }

            loadedSettingsFile = settingsFileToDeserialize;
            Options options = XmlFileSerializer <Options> .Deserialize(settingsFileToDeserialize.FullName);

            Instance.ResolveAndUnresolveReferencesOnOpenAndClose = options.ResolveAndUnresolveReferencesOnOpenAndClose;
            Instance.DependenciesPattern = options.DependenciesPattern;
            Instance.WorkspacePath       = options.WorkspacePath;
            Instance.RetrieveCommand     = options.RetrieveCommand;
        }