예제 #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>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            var oleMenuCommandService = await this.GetServiceAsync <IMenuCommandService, OleMenuCommandService>();

            var componentModel = await this.GetServiceAsync <SComponentModel, IComponentModel>();

            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            var visualStudioWorkspace = componentModel.GetService <VisualStudioWorkspace>();
            var codeConversion        = await CodeConversion.CreateAsync(this, visualStudioWorkspace, this.GetDialogPageAsync <ConverterOptionsPage>);

            ConvertCSToVBCommand.Initialize(this, oleMenuCommandService, codeConversion);
            ConvertVBToCSCommand.Initialize(this, oleMenuCommandService, codeConversion);
            PasteAsVB.Initialize(this, oleMenuCommandService, codeConversion);
            PasteAsCS.Initialize(this, oleMenuCommandService, codeConversion);
            VisualStudioInteraction.Initialize(PackageCancellation);
            await TaskScheduler.Default;
            await base.InitializeAsync(cancellationToken, progress);
        }
예제 #2
0
 /// <remarks>
 ///     Must be called from UI thread
 /// </remarks>
 public static void Initialize(CodeConverterPackage package, OleMenuCommandService menuCommandService,
                               CodeConversion codeConversion)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     Instance = new PasteAsCS(package, codeConversion, menuCommandService);
 }