Ejemplo n.º 1
0
        private void InitializeDTE()
        {
            IVsShell shellService;

            dte = GetService(typeof(SDTE)) as EnvDTE80.DTE2;

            var extendedLog = false;
            var settings    = ProjectHelper.GetSettings();

            if (settings != null && settings.CrmConnections != null)
            {
                extendedLog = settings.CrmConnections.ExtendedLog;
            }

            if (dte == null) // The IDE is not yet fully initialized
            {
                Logger.WriteLine("Warning: DTE service is null. Seems that VisualStudio is not fully initialized.", extendedLog);
                Logger.WriteLine("Waiting for DTE.", extendedLog);
                shellService   = GetService(typeof(SVsShell)) as IVsShell;
                dteInitializer = new DteInitializer(shellService, InitializeDTE);
            }
            else
            {
                Logger.WriteLine("DTE service found.", extendedLog);
                dteInitializer = null;
                UpdateWebResources.Initialize(this);
                UpdaterOptions.Initialize(this);
                UpdateSelectedWebResources.Initialize(this);
                CreateWebResource.Initialize(this);
            }
        }
Ejemplo n.º 2
0
        private async Task InitializeDTEAsync(CancellationToken cancellationToken)
        {
            var dteObj = (EnvDTE80.DTE2) await this.GetServiceAsync(typeof(EnvDTE.DTE));

            var settings = await SettingsService.Instance.GetSettingsAsync();

            var extendedLog = false;

            if (settings != null && settings.CrmConnections != null)
            {
                extendedLog = settings.CrmConnections.ExtendedLog;
            }

            if (dteObj == null) // The IDE is not yet fully initialized
            {
                await Logger.WriteLineAsync("Warning: DTE service is null. Seems that VisualStudio is not fully initialized.", extendedLog);

                //Logger.WriteLine("Waiting for DTE.", extendedLog);
                //var shellService = await this.GetServiceAsync(typeof(SVsShell)) as IVsShell;
                //this.dteInitializer = new DteInitializer(shellService, this.InitializeDTE);
            }
            else
            {
                try
                {
                    await Logger.WriteLineAsync("DTE service found.", extendedLog);

                    UpdateWebResources.Initialize(this);
                    UpdaterOptions.Initialize(this);
                    UpdateSelectedWebResources.Initialize(this);
                    CreateWebResource.Initialize(this);

                    await JoinableTaskFactory.SwitchToMainThreadAsync();

                    //Microsoft.VisualStudio.Shell.Events.SolutionEvents.OnAfterCloseSolution +=
                    //(object sender, EventArgs args) =>

                    //dteObj.Events.DTEEvents.OnBeginShutdown +=
                    //() =>
                    //{
                    //    watchdogService.Shutdown();
                    //};
                }
                catch (Exception)
                {
                    await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
                }
            }
        }
Ejemplo n.º 3
0
        private async Task InitializeDTE(CancellationToken cancellationToken)
        {
            var dteObj = await this.GetServiceAsync(typeof(EnvDTE.DTE));

            var settings = await SettingsService.Instance.GetSettingsAsync();

            var extendedLog = false;

            if (settings != null && settings.CrmConnections != null)
            {
                extendedLog = settings.CrmConnections.ExtendedLog;
            }

            if (dteObj == null) // The IDE is not yet fully initialized
            {
                Logger.WriteLine("Warning: DTE service is null. Seems that VisualStudio is not fully initialized.", extendedLog);
                //Logger.WriteLine("Waiting for DTE.", extendedLog);
                //var shellService = await this.GetServiceAsync(typeof(SVsShell)) as IVsShell;
                //this.dteInitializer = new DteInitializer(shellService, this.InitializeDTE);
            }
            else
            {
                try
                {
                    Logger.WriteLine("DTE service found.", extendedLog);
                    UpdateWebResources.Initialize(this);
                    UpdaterOptions.Initialize(this);
                    UpdateSelectedWebResources.Initialize(this);
                    CreateWebResource.Initialize(this);
                }
                catch (Exception ex)
                {
                    await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
                }
            }
        }
 /// <summary>
 /// Initializes the singleton instance of the command.
 /// </summary>
 /// <param name="package">Owner package, not null.</param>
 public static void Initialize(AsyncPackage package)
 {
     Instance = new CreateWebResource(package);
 }