// constructor private SolutionEventHandlers(DTE dte, DTE2 dte2) { ThreadHelper.ThrowIfNotOnUIThread(); _dte = dte; _dte2 = dte2; myEvents = dte.Events; myDocumentEvents = dte.Events.DocumentEvents; myDocumentEvents.DocumentOpened += (doc) => { // The outer delegate is synchronous, but kicks off async work via a method that accepts an async delegate. _ = ThreadHelper.JoinableTaskFactory.RunAsync(async delegate { await myDocumentEvents_DocumentOpenedAsync(doc); }); }; myDocumentEvents.DocumentSaved += (doc) => { // The outer delegate is synchronous, but kicks off async work via a method that accepts an async delegate. _ = ThreadHelper.JoinableTaskFactory.RunAsync(async delegate { await myDocumentEvents_DocumentSavedAsync(doc); }); }; CSharpProjectItemsEvents = (ProjectItemsEvents)dte.Events.GetObject("CSharpProjectItemsEvents"); CSharpProjectItemsEvents.ItemRenamed += CSharpItemRenamed; myEvents.SolutionEvents.Opened += SolutionEvents_Opened; _VSOutputWindow = new VSOutputWindow(_dte2); }
private void ProcessAllItems(ProjectItems items, VSOutputWindow vsOutputWindow) { if (items != null) { foreach (ProjectItem item in items) { try { if (item.FileNames[1].EndsWith(".sql")) { item.Open(); var textDoc = ((TextDocument)item.Document.Object()); var text = textDoc.CreateEditPoint().GetText(textDoc.EndPoint); if (text.Contains("managed by QueryFirst")) { var ctx = TinyIoC.TinyIoCContainer.Current.Resolve <ICodeGenerationContext>(); new Conductor(vsOutputWindow, ctx).ProcessOneQuery(item.Document); } } if (item.Kind == "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}") //folder { ProcessAllItems(item.ProjectItems, vsOutputWindow); } } catch (Exception ex) { } } } }
private void ProcessAllItems(ProjectItems items, VSOutputWindow vsOutputWindow) { ThreadHelper.ThrowIfNotOnUIThread(); if (items != null) { foreach (ProjectItem item in items) { try { if (item.FileNames[1].EndsWith(".sql")) { item.Open(); var textDoc = ((TextDocument)item.Document.Object()); var text = textDoc.CreateEditPoint().GetText(textDoc.EndPoint); if (text.Contains("managed by QueryFirst")) { new Conductor(vsOutputWindow, null, null).ProcessOneQuery(item.Document); } } if (item.Kind == "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}") //folder { ProcessAllItems(item.ProjectItems, vsOutputWindow); } } catch (Exception ex) { vsOutputWindow.Write(ex.ToString()); } } } }
public Conductor(VSOutputWindow vSOutputWindow, IWrapperClassMaker wrapperClassMaker, IResultClassMaker resultClassMaker) { _tiny = TinyIoCContainer.Current; _wrapper = wrapperClassMaker ?? _tiny.Resolve <IWrapperClassMaker>(); _results = resultClassMaker ?? _tiny.Resolve <IResultClassMaker>(); _vsOutputWindow = vSOutputWindow; }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { DTE2 dte2 = ServiceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2;//Package.GetGlobalService(typeof(DTE)) as DTE2; var vsOutputWindow = new VSOutputWindow(dte2); foreach (Project proj in ((QueryFirstCmdPackage)_package).dte.Solution.Projects) { ProcessAllItems(proj.ProjectItems, vsOutputWindow); } return; }
// constructor private SolutionEventHandlers(DTE dte, DTE2 dte2) { _dte = dte; _dte2 = dte2; myEvents = dte.Events; myDocumentEvents = dte.Events.DocumentEvents; myDocumentEvents.DocumentSaved += myDocumentEvents_DocumentSaved; CSharpProjectItemsEvents = (ProjectItemsEvents)dte.Events.GetObject("CSharpProjectItemsEvents"); CSharpProjectItemsEvents.ItemRenamed += CSharpItemRenamed; myEvents.SolutionEvents.Opened += SolutionEvents_Opened; _VSOutputWindow = new VSOutputWindow(_dte2); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { DTE2 dte2; dte2 = (DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.12.0"); var vsOutputWindow = new VSOutputWindow(dte2); foreach (Project proj in ((QueryFirstCmdPackage)_package).dte.Solution.Projects) { ProcessAllItems(proj.ProjectItems, vsOutputWindow); } return; }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); DTE2 dte2 = ServiceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2;//Package.GetGlobalService(typeof(DTE)) as DTE2; var vsOutputWindow = new VSOutputWindow(dte2); RegisterTypes.Instance.Register(vsOutputWindow, false); foreach (Project proj in ((QueryFirstCmdPackage)_package).dte.Solution.Projects) { ProcessAllItems(proj.ProjectItems, vsOutputWindow); } return; }
public void Register(VSOutputWindow outputWindow, bool force = false) { try { var ctr = TinyIoCContainer.Current; //kludge if (force == true) { ctr.Dispose(); } else if (TinyIoCContainer.Current.CanResolve <IWrapperClassMaker>()) { //_VSOutputWindow.Write("Already registered\n"); return; } System.Configuration.KeyValueConfigurationElement helperAssembly = null; List <Assembly> assemblies = new List <Assembly>(); if (helperAssembly != null && !string.IsNullOrEmpty(helperAssembly.Value)) { assemblies.Add(Assembly.LoadFrom(helperAssembly.Value)); } assemblies.Add(Assembly.GetExecutingAssembly()); TinyIoCContainer.Current.AutoRegister(assemblies, DuplicateImplementationActions.RegisterSingle); // IProvider, for instance, has multiple implementations. To resolve we use the provider name on the connection string, // which must correspond to the fully qualified name of the implementation. ie. QueryFirst.Providers.SqlClient for SqlServer //_VSOutputWindow.Write("Registered types...\n"); } catch { //outputWindow.Write(ex.Message + '\n' + ex.StackTrace); } }
public Conductor(VSOutputWindow vsOutpuWindow, ICodeGenerationContext ctx) { _vsOutputWindow = vsOutpuWindow; _ctx = ctx; }
public Conductor(VSOutputWindow vsOutpuWindow) { _vsOutputWindow = vsOutpuWindow; }