UnityEditor.SyncVS.DeriveVisualStudioPath C# (CSharp) Method

DeriveVisualStudioPath() private static method

private static DeriveVisualStudioPath ( string debuggerPath ) : string
debuggerPath string
return string
        private static string DeriveVisualStudioPath(string debuggerPath)
        {
            string a = DeriveProgramFilesSentinel();
            string str2 = "Common7";
            bool flag = false;
            char[] separator = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
            string[] strArray = debuggerPath.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            foreach (string str4 in strArray)
            {
                if (!flag && string.Equals(a, str4, StringComparison.OrdinalIgnoreCase))
                {
                    flag = true;
                }
                else if (flag)
                {
                    folderPath = Path.Combine(folderPath, str4);
                    if (string.Equals(str2, str4, StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
            string[] components = new string[] { folderPath, "IDE", "devenv.exe" };
            return Paths.Combine(components);
        }

Usage Example

示例#1
0
        private static IDictionary <VisualStudioVersion, string> GetInstalledVisualStudios()
        {
            Dictionary <VisualStudioVersion, string> dictionary = new Dictionary <VisualStudioVersion, string>();

            if (SyncVS.SolutionSynchronizationSettings.IsWindows)
            {
                IEnumerator enumerator = Enum.GetValues(typeof(VisualStudioVersion)).GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        VisualStudioVersion visualStudioVersion = (VisualStudioVersion)enumerator.Current;
                        try
                        {
                            string text = Environment.GetEnvironmentVariable(string.Format("VS{0}0COMNTOOLS", (int)visualStudioVersion));
                            if (!string.IsNullOrEmpty(text))
                            {
                                string text2 = Paths.Combine(new string[]
                                {
                                    text,
                                    "..",
                                    "IDE",
                                    "devenv.exe"
                                });
                                if (File.Exists(text2))
                                {
                                    dictionary[visualStudioVersion] = text2;
                                    continue;
                                }
                            }
                            text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\{0}.0", (int)visualStudioVersion), "InstallDir");
                            if (string.IsNullOrEmpty(text))
                            {
                                text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\{0}.0", (int)visualStudioVersion), "InstallDir");
                            }
                            if (!string.IsNullOrEmpty(text))
                            {
                                string text3 = Paths.Combine(new string[]
                                {
                                    text,
                                    "devenv.exe"
                                });
                                if (File.Exists(text3))
                                {
                                    dictionary[visualStudioVersion] = text3;
                                    continue;
                                }
                            }
                            text = SyncVS.GetRegistryValue(string.Format("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\{0}.0\\Debugger", (int)visualStudioVersion), "FEQARuntimeImplDll");
                            if (!string.IsNullOrEmpty(text))
                            {
                                string text4 = SyncVS.DeriveVisualStudioPath(text);
                                if (!string.IsNullOrEmpty(text4) && File.Exists(text4))
                                {
                                    dictionary[visualStudioVersion] = SyncVS.DeriveVisualStudioPath(text);
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                finally
                {
                    IDisposable disposable;
                    if ((disposable = (enumerator as IDisposable)) != null)
                    {
                        disposable.Dispose();
                    }
                }
            }
            return(dictionary);
        }
All Usage Examples Of UnityEditor.SyncVS::DeriveVisualStudioPath