/// <summary> /// Gets the user snippet directories. These are used for the save as dialog /// </summary> private void GetUserSnippetDirectories() { string vsDocDir = RegistryLocations.GetVisualStudioUserDataPath(SnippetDesignerPackage.Instance.VSVersion); string snippetDir = Path.Combine(vsDocDir, StringConstants.SnippetDirectoryName); userSnippetDirectories[Resources.DisplayNameCSharp] = Path.Combine(snippetDir, Path.Combine(StringConstants.SnippetDirNameCSharp, StringConstants.MySnippetsDir)); userSnippetDirectories[Resources.DisplayNameVisualBasic] = Path.Combine(snippetDir, Path.Combine(StringConstants.SnippetDirNameVisualBasic, StringConstants.MySnippetsDir)); userSnippetDirectories[Resources.DisplayNameXML] = Path.Combine(snippetDir, Path.Combine(StringConstants.SnippetDirNameXML, StringConstants.MyXmlSnippetsDir)); userSnippetDirectories[Resources.DisplayNameSQL] = Path.Combine(snippetDir, Path.Combine(StringConstants.SnippetDirNameSQL, StringConstants.MySnippetsDir)); if (!SnippetDesignerPackage.Instance.IsVisualStudio2010) { userSnippetDirectories[Resources.DisplayNameCPP] = Path.Combine(snippetDir, Path.Combine(StringConstants.SnippetDirNameCPP, StringConstants.MySnippetsDir)); userSnippetDirectories[Resources.DisplayNameJavaScript] = Path.Combine(snippetDir, Path.Combine(StringConstants.SnippetDirNameJavaScriptVS11, StringConstants.MySnippetsDir)); } if (!SnippetDesignerPackage.Instance.IsVisualStudio2010 && !SnippetDesignerPackage.Instance.IsVisualStudio2012) { userSnippetDirectories[Resources.DisplayNameXAML] = Path.Combine(snippetDir, StringConstants.SnippetDirNameXAML); } var webDevSnippetDir = Path.Combine(snippetDir, StringConstants.VisualWebDeveloper); if (SnippetDesignerPackage.Instance.IsVisualStudio2010) { userSnippetDirectories[Resources.DisplayNameJavaScript] = Path.Combine(webDevSnippetDir, StringConstants.SnippetDirNameJavaScript); } userSnippetDirectories[Resources.DisplayNameHTML] = Path.Combine(webDevSnippetDir, StringConstants.SnippetDirNameHTML); userSnippetDirectories[String.Empty] = snippetDir; }
/// <summary> /// Initializes a new instance of the <see cref="SnippetDirectories"/> class. /// </summary> private SnippetDirectories() { var version = SnippetDesignerPackage.Instance.VSVersion; IUIHostLocale localeHost = (IUIHostLocale)SnippetDesignerPackage.Instance.GetService(typeof(IUIHostLocale)); uint lcid = (uint)CultureInfo.CurrentCulture.LCID; localeHost.GetUILocale(out lcid); registryPathReplacements.Add("%InstallRoot%", GetInstallRoot(version)); registryPathReplacements.Add("%LCID%", lcid.ToString()); registryPathReplacements.Add("%MyDocs%", RegistryLocations.GetVisualStudioUserDataPath(version)); replaceRegex = new Regex("(%InstallRoot%)|(%LCID%)|(%MyDocs%)", RegexOptions.Compiled); GetUserSnippetDirectories(); GetSnippetDirectoriesFromRegistry(Registry.LocalMachine, false, version); GetSnippetDirectoriesFromRegistry(Registry.CurrentUser, true, version); }