예제 #1
0
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await JoinableTaskFactory.SwitchToMainThreadAsync();

            var manager = await GetServiceAsync(typeof(SVsExtensionManager)) as IVsExtensionManager;

            var repository = await GetServiceAsync(typeof(SVsExtensionRepository)) as IVsExtensionRepository;

            var extService = new ExtensionService(manager, repository);
            var solService = await GetServiceAsync(typeof(SVsSolution)) as IVsSolution;

            var isSolutionLoaded = await IsSolutionLoadedAsync(solService);

            if (isSolutionLoaded)
            {
                JoinableTaskFactory.RunAsync(() =>
                {
                    return(HandleOpenSolutionAsync(solService, extService, cancellationToken));
                }).FileAndForget($"{nameof(ExtensionManager)}/{nameof(HandleOpenSolutionAsync)}");;
            }

            // Listen for subsequent solution events
            SolutionEvents.OnAfterOpenSolution += (s, e) => HandleOpenSolutionAsync(solService, extService, cancellationToken).ConfigureAwait(false);

            if (await GetServiceAsync(typeof(IMenuCommandService)) is OleMenuCommandService commandService)
            {
                ExportCommand.Initialize(this, commandService, extService);
                ExportSolutionCommand.Initialize(this, commandService, extService);
                ImportCommand.Initialize(this, commandService, extService);
            }
        }
예제 #2
0
 public static void Initialize(Package package, OleMenuCommandService commandService, ExtensionService es)
 {
     Instance = new ExportCommand(package, commandService, es);
 }