Esempio n. 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);
            }
        }
 public static void Initialize(AsyncPackage package, OleMenuCommandService commandService, ExtensionService es)
 {
     Instance = new ImportCommand(package, commandService, es);
 }