public CommandRouter(IPackageOption packageOption, AbstractSwitch projectSwitch, AbstractSwitch packageSwitch, AbstractSwitch librarySwitch) { _packageOption = packageOption; _projectSwitch = projectSwitch; _packageSwitch = packageSwitch; _librarySwitch = librarySwitch; }
/// <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> /// /// <param name="cancellationToken"> /// A cancellation token to monitor /// for initialization cancellation, /// which can occur when VS is /// shutting down. /// </param> /// /// <param name="progress"> /// A provider for progress updates. /// </param> /// /// <returns> /// A task representing the async work of package initialization, /// or an already completed task if there is none. Do not return /// null from this method. /// </returns> protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); OleMenuCommandService oleMenuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; IVsSolution vsSolution = await GetServiceAsync(typeof(IVsSolution)) as IVsSolution; await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); IMessageHelper messageHelper = new MessageHelper(vsSolution, new ErrorListProvider(this)); IProjectHelper projectHelper = new ProjectHelper(); IPackageOption packageOption = (PackageOption)GetDialogPage(typeof(PackageOption)); ((PackageOption)packageOption).Init(messageHelper); AbstractSwitch projectSwtich = new ProjectSwitch(true, ReferenceType.ProjectReference, packageOption, projectHelper, messageHelper); AbstractSwitch packageSwitch = new PackageSwitch(true, ReferenceType.PackageReference, packageOption, projectHelper, messageHelper); AbstractSwitch librarySwitch = new LibrarySwitch(true, ReferenceType.Reference, packageOption, projectHelper, messageHelper); ICommandRouter commandRouter = new CommandRouter(packageOption, projectSwtich, packageSwitch, librarySwitch); new CommandProject(commandRouter, messageHelper).Initialize(oleMenuCommandService, new Guid("c6018e68-fcab-41d2-a34a-42f7df92b162"), 0x0100); new CommandPackage(commandRouter, messageHelper).Initialize(oleMenuCommandService, new Guid("c6018e68-fcab-41d2-a34a-42f7df92b162"), 0x0200); new CommandLibrary(commandRouter, messageHelper).Initialize(oleMenuCommandService, new Guid("c6018e68-fcab-41d2-a34a-42f7df92b162"), 0x0300); }
/// <param name="isVSIX"> /// Indicates that the call /// is from Visual Studio. /// </param> protected AbstractSwitch(bool isVSIX, ReferenceType type, IPackageOption packageOption, IProjectHelper projectHelper, IMessageHelper messageHelper) { IsVSIX = isVSIX; if (IsVSIX) { DTE = Package.GetGlobalService(typeof(DTE)) as DTE; } Type = type; PackageOption = packageOption; ProjectHelper = projectHelper; MessageHelper = messageHelper; }
public PackageSwitch(bool isVSIX, ReferenceType type, IPackageOption packageOption, IProjectHelper projectHelper, IMessageHelper messageHelper) : base(isVSIX, type, packageOption, projectHelper, messageHelper) { }