Exemplo n.º 1
0
        public async Task Package_after_create_actions_are_not_run_more_than_once()
        {
            var afterCreateCallCount = 0;

            var initializer = new PackageInitializer(
                "console",
                "test",
                afterCreate: async(_, __) =>
            {
                await Task.Yield();
                afterCreateCallCount++;
            });

            var package = Create.EmptyWorkspace(initializer: initializer);

            await package.CreateRoslynWorkspaceForRunAsync(new TimeBudget(30.Seconds()));

            await package.CreateRoslynWorkspaceForRunAsync(new TimeBudget(30.Seconds()));

            afterCreateCallCount.Should().Be(1);
        }
        /// <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 initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            PackageInitializer.Initialize(this);

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

            if (null != mcs)
            {
                // Create the command for the Add New WCF Projects.
                var addWcfCommandID = new CommandID(GuidList.guidServiceFactory_PackageCmdSet, (int)PkgCmdIDList.cmdAddNewWcfProject);
                var addWcfMenuItem  = new MenuCommand(AddWcfCallback, addWcfCommandID); // { Enabled = DteLanguage.IsCSharpOrVbProject(this, true) };
                mcs.AddCommand(addWcfMenuItem);

                // Create the command for the Add New ASMX Projects.
                var addAsmxCommandID = new CommandID(GuidList.guidServiceFactory_PackageCmdSet, (int)PkgCmdIDList.cmdAddNewAsmxProject);
                var addAsmxMenuItem  = new MenuCommand(AddAsmxCallback, addAsmxCommandID);
                mcs.AddCommand(addAsmxMenuItem);

                // Create the command for the PMT
                var addPmtCommandID = new CommandID(GuidList.guidServiceFactory_PackageCmdSet, (int)PkgCmdIDList.cmdAddPmt);
                var addPmtMenuItem  = new MenuCommand(AddPmtCallback, addPmtCommandID);
                mcs.AddCommand(addPmtMenuItem);

                // Create the command for the CA
                var addSemanticCACommandID = new CommandID(GuidList.guidServiceFactory_PackageCmdSet, (int)PkgCmdIDList.cmdSemanticCA);
                var addSemanticCAMenuItem  = new MenuCommand(AddSemanticCaCallback, addSemanticCACommandID);
                mcs.AddCommand(addSemanticCAMenuItem);

                // Create the command for the Security CA
                var addSecurityCACommandID = new CommandID(GuidList.guidServiceFactory_PackageCmdSet, (int)PkgCmdIDList.cmdSecurityCA);
                var addSecurityCAMenuItem  = new MenuCommand(AddSecurityCaCallback, addSecurityCACommandID);
                mcs.AddCommand(addSecurityCAMenuItem);
            }
        }
Exemplo n.º 3
0
 protected override int QueryClose(out bool canClose)
 {
     PackageInitializer.Shutdown();
     // perform resources clean up
     return(base.QueryClose(out canClose));
 }
Exemplo n.º 4
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 initilaization code that rely on services provided by VisualStudio.
 /// </summary>
 protected override void Initialize()
 {
     base.Initialize();
     PackageInitializer.Initialize(this);
 }
 protected override int QueryClose(out bool canClose)
 {
     PackageInitializer.Shutdown();
     return(base.QueryClose(out canClose));
 }