Пример #1
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            var objDte = await GetServiceAsync(typeof(DTE));

            _dte = objDte as DTE;

            var metadata = new Metadata
            {
                EditorName    = "visualstudio",
                PluginName    = "visualstudio-wakatime",
                EditorVersion = _dte == null ? string.Empty : _dte.Version,
                PluginVersion = Constants.PluginVersion
            };

            _logger   = new Logger(Dependencies.GetConfigFilePath());
            _wakatime = new Shared.ExtensionUtils.WakaTime(metadata, _logger);

            _logger.Debug("It will load WakaTime extension");

            await InitializeAsync(cancellationToken);

            // Prompt for api key if not already set
            if (string.IsNullOrEmpty(_wakatime.Config.GetSetting("api_key")))
            {
                PromptApiKey();
            }
        }
Пример #2
0
        protected override void Initialize()
        {
            base.Initialize();

            AddSkipLoading();

            _dte       = (DTE)GetService(typeof(DTE));
            _dteEvents = _dte.Events.DTEEvents;
            _dteEvents.OnStartupComplete += OnOnStartupComplete;

            var metadata = new Metadata
            {
                EditorName    = "ssms",
                PluginName    = "ssms-wakatime",
                EditorVersion = _dte == null ? string.Empty : _dte.Version,
                PluginVersion = Constants.PluginVersion
            };

            _logger   = new Logger(Dependencies.GetConfigFilePath());
            _wakatime = new Shared.ExtensionUtils.WakaTime(metadata, _logger);

            _logger.Debug("It will load WakaTime extension");

            Task.Run(() =>
            {
                InitializeAsync();
            });
        }