Exemplo n.º 1
0
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <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)
        {
            Debug.WriteLine($"Entering {nameof(InitializeAsync)}() of: {this}");

            await base.InitializeAsync(cancellationToken, progress);

            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            cancellationToken.ThrowIfCancellationRequested();

            var componentModel = (IComponentModel) await GetServiceAsync(typeof(SComponentModel));

            Assumes.Present(componentModel);

            // Add our command handlers for menu (commands must exist in the .vsct file)
            this.menuService = (OleMenuCommandService) await GetServiceAsync(typeof(IMenuCommandService));

            Assumes.Present(menuService);

            this.workspace = componentModel.GetService <VisualStudioWorkspace>();
            Assumes.Present(workspace);

            OpenILSpyCommand.Register(this);
            OpenProjectOutputCommand.Register(this);
            OpenReferenceCommand.Register(this);
            OpenCodeItemCommand.Register(this);
        }
Exemplo n.º 2
0
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <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()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            this.menuService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            var componentModel = (IComponentModel)this.GetService(typeof(SComponentModel));

            this.workspace = componentModel.GetService <VisualStudioWorkspace>();

            if (menuService == null || workspace == null)
            {
                return;
            }

            OpenILSpyCommand.Register(this);
            OpenProjectOutputCommand.Register(this);
            OpenReferenceCommand.Register(this);
            OpenCodeItemCommand.Register(this);
        }