Esempio n. 1
0
        private string GetConfigPathForItem(string path)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(path))
                {
                    return(null);
                }

                var solutionRoot = String.IsNullOrEmpty(_dte.Solution?.FullName)
                    ? String.Empty
                    : Path.GetDirectoryName(_dte.Solution.FullName);

                IEnumerator <string> configPaths
                    = (path.StartsWith(solutionRoot, StringComparison.InvariantCultureIgnoreCase))
                        ? StylerPackage.GetConfigPathInsideSolution(path, solutionRoot).GetEnumerator()
                        : StylerPackage.GetConfigPathOutsideSolution(path).GetEnumerator();

                while (configPaths.MoveNext())
                {
                    if (File.Exists(configPaths.Current))
                    {
                        return(configPaths.Current);
                    }
                }
            }
            catch
            {
                // Fail gracefully.
            }

            return(null);
        }