コード例 #1
0
        /// <inheritdoc />
        /// <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>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            try {
                // Switches to the UI thread in order to consume some services used in command initialization
                await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

                // Query service asynchronously from the UI thread
                _dte = await GetServiceAsync(typeof(SDTE)) as DTE;

                Assumes.Present(_dte);
                _dteEvents = _dte.Events;
                _dteEvents.WindowEvents.WindowActivated += OnWindowSwitch;

                if (Settings.IsPresenceEnabled)
                {
                    DiscordController.Initialize();
                    DiscordRPC.UpdatePresence(ref DiscordController.Presence);
                }

                PresenceCommand.Initialize(this);
                await base.InitializeAsync(cancellationToken, progress);
            }
            catch (Exception) {
                //ignored
            }
        }
コード例 #2
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>
        protected override void Initialize()
        {
            // Try to deserialize the config file, it should throw an error if it doesn't exist.
            // in that case, we'll want to create a new instance and save it.
            _dte       = (DTE)GetService(typeof(SDTE));
            _dteEvents = _dte.Events;
            _dteEvents.WindowEvents.WindowActivated += OnWindowSwitch;

            if (Settings.IsPresenceEnabled)
            {
                DiscordController.Initialize();

                DiscordRPC.UpdatePresence(ref DiscordController.presence);
            }

            base.Initialize();
            PresenceCommand.Initialize(this);
        }
コード例 #3
0
 /// <summary>
 ///     Initializes the singleton instance of the command.
 /// </summary>
 /// <param name="package">Owner package, not null.</param>
 public static void Initialize(Package package)
 {
     Instance = new PresenceCommand(package);
 }