private void GetRegistryIncludeFolders(List <string> includeFolders) { string extension = Path.GetExtension(this.inputFile); if (!string.IsNullOrEmpty(extension)) { OrchestratorPackage singleton = OrchestratorPackage.Singleton; if (singleton != null) { string name = @"TextTemplating\IncludeFolders\" + extension; using (RegistryKey key = singleton.ApplicationRegistryRoot.OpenSubKey(name, false)) { if (key != null) { string[] valueNames = key.GetValueNames(); Array.Sort <string>(valueNames, StringComparer.OrdinalIgnoreCase); foreach (string str3 in valueNames) { if (str3.StartsWith("include", StringComparison.OrdinalIgnoreCase)) { string str4 = key.GetValue(str3) as string; if (!string.IsNullOrEmpty(str4)) { includeFolders.Add(str4); } } } } } } } }
internal TextTemplatingService(OrchestratorPackage package) { DTE dTE = package.GetDTE(); this.package = package; this.engine = new Microsoft.VisualStudio.TextTemplating.Engine(); this.serviceProvider = new ServiceProvider(dTE as Microsoft.VisualStudio.OLE.Interop.IServiceProvider); this.errorProvider = new ErrorListProvider(this.serviceProvider); this.errorProvider.MaintainInitialTaskOrder = true; dTE.Events.SolutionEvents.add_AfterClosing(new _dispSolutionEvents_AfterClosingEventHandler(this.SolutionEvents_AfterClosing)); }
public string ResolveAssemblyReference(string assemblyReference) { if (!string.IsNullOrWhiteSpace(assemblyReference)) { assemblyReference = this.ExpandAllVariables(assemblyReference); if (Path.IsPathRooted(assemblyReference)) { Zone zone = Zone.CreateFromUrl(new Uri(assemblyReference).AbsoluteUri); if ((zone.SecurityZone == SecurityZone.Trusted) || (zone.SecurityZone == SecurityZone.MyComputer)) { return(assemblyReference); } this.LogError(false, string.Format(CultureInfo.CurrentCulture, Microsoft.VisualStudio.TextTemplating.VSHost.Resources.AssemblyReferenceFailed, new object[] { string.Format(CultureInfo.CurrentCulture, Microsoft.VisualStudio.TextTemplating.VSHost.Resources.PathNotTrusted, new object[] { assemblyReference }) }), -1, -1, this.inputFile); return(string.Empty); } string location = GlobalAssemblyCacheHelper.GetLocation(assemblyReference); if (!string.IsNullOrEmpty(location)) { return(location); } OrchestratorPackage singleton = OrchestratorPackage.Singleton; if (singleton != null) { string vSInstallDir = GetVSInstallDir(singleton.ApplicationRegistryRoot); if (!string.IsNullOrEmpty(vSInstallDir)) { location = Path.Combine(Path.Combine(vSInstallDir, "PublicAssemblies"), assemblyReference); if (File.Exists(location)) { return(location); } } } IVsExtensionManager service = this.serviceProvider.GetService(typeof(SVsExtensionManager)) as IVsExtensionManager; if (service != null) { location = this.ResolveAssemblyReferenceViaExtensionManager(assemblyReference, service); if (!string.IsNullOrEmpty(location)) { return(location); } } } return(assemblyReference); }
protected override void Dispose(bool disposing) { try { if (disposing) { singletonInstance = null; ((IServiceContainer)this).RemoveService(typeof(STextTemplating), true); if (this.solutionEvents != null) { this.solutionEvents.remove_AfterClosing(new _dispSolutionEvents_AfterClosingEventHandler(this.OnSolutionClose)); this.solutionEvents = null; } } } finally { base.Dispose(disposing); } }
private static bool GetBooleanOption(string optionValueName, bool defaultValue) { bool flag = defaultValue; string name = "TextTemplating"; OrchestratorPackage singleton = OrchestratorPackage.Singleton; if (singleton != null) { using (RegistryKey key = singleton.ApplicationRegistryRoot.OpenSubKey(name, false)) { if (key != null) { object obj2 = key.GetValue(optionValueName, defaultValue); if (obj2 != null) { flag = Convert.ToBoolean(obj2, CultureInfo.InvariantCulture); } } } } return(flag); }
public Type ResolveDirectiveProcessor(string processorName) { OrchestratorPackage singleton = OrchestratorPackage.Singleton; if (singleton != null) { string name = @"TextTemplating\DirectiveProcessors\" + processorName; using (RegistryKey key = singleton.ApplicationRegistryRoot.OpenSubKey(name, false)) { if (key != null) { List <string> list = new List <string>(key.GetValueNames()); string str2 = key.GetValue("Class") as string; if (!string.IsNullOrEmpty(str2)) { string str3 = string.Empty; Assembly assembly = null; try { if (list.Contains("Assembly")) { str3 = key.GetValue("Assembly") as string; if (!string.IsNullOrEmpty(str3)) { assembly = Assembly.Load(str3); } } else if (list.Contains("CodeBase")) { str3 = key.GetValue("CodeBase") as string; if (!string.IsNullOrEmpty(str3)) { assembly = Assembly.LoadFrom(str3); } } if (assembly == null) { throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Microsoft.VisualStudio.TextTemplating.VSHost.Resources.TypeResolveFailed, new object[] { processorName })); } } catch (Exception exception) { this.LogError(true, string.Format(CultureInfo.CurrentCulture, Microsoft.VisualStudio.TextTemplating.VSHost.Resources.DPAssemblyLoadFail, new object[] { str3, processorName, exception.ToString() }), -1, -1, this.inputFile); throw; } if (!assembly.PermissionSet.IsUnrestricted()) { this.LogError(true, string.Format(CultureInfo.CurrentCulture, Microsoft.VisualStudio.TextTemplating.VSHost.Resources.NoFullTrust, new object[] { assembly.FullName, processorName }), -1, -1, this.inputFile); throw new SecurityException(string.Format(CultureInfo.CurrentCulture, Microsoft.VisualStudio.TextTemplating.VSHost.Resources.NoFullTrust, new object[] { assembly.FullName, processorName })); } try { Type type = assembly.GetType(str2); if (type == null) { throw new InvalidCastException(string.Format(CultureInfo.CurrentCulture, Microsoft.VisualStudio.TextTemplating.VSHost.Resources.TypeResolveFailed, new object[] { processorName })); } return(type); } catch (Exception exception2) { this.LogError(true, string.Format(CultureInfo.CurrentCulture, Microsoft.VisualStudio.TextTemplating.VSHost.Resources.DPTypeLoadFail, new object[] { str2, str3, processorName, exception2.ToString() }), -1, -1, this.inputFile); throw; } } } } } throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Microsoft.VisualStudio.TextTemplating.VSHost.Resources.TypeResolveFailed, new object[] { processorName })); }
private void CreateTextTemplatingService(OrchestratorPackage package) { this.textTemplatingService = new TextTemplatingService(package); }
public OrchestratorPackage() { singletonInstance = this; }