コード例 #1
0
        protected override void Initialize()
        {
            base.Initialize();

            // Subscribe to the solution events
            this.solutionListeners.Add(new SolutionListenerForProjectReferenceUpdate(this));
            this.solutionListeners.Add(new SolutionListenerForProjectOpen(this));
            this.solutionListeners.Add(new SolutionListenerForBuildDependencyUpdate(this));
            this.solutionListeners.Add(new SolutionListenerForProjectEvents(this));

            foreach (SolutionListener solutionListener in this.solutionListeners)
            {
                solutionListener.Init();
            }

            try
            {
                // this block assumes that the ProjectPackage instances will all be initialized on the same thread,
                // but doesn't assume that only one ProjectPackage instance exists at a time
                if (Interlocked.Increment(ref _singleFileGeneratorNodeExtenderReferenceCount) == 1)
                {
                    ObjectExtenders objectExtenders = (ObjectExtenders)GetService(typeof(ObjectExtenders));
                    _singleFileGeneratorNodeExtenderProvider = new SingleFileGeneratorNodeExtenderProvider();
                    string extenderCatId = typeof(FileNodeProperties).GUID.ToString("B");
                    string extenderName  = SingleFileGeneratorNodeExtenderProvider.Name;
                    string localizedName = extenderName;
                    _singleFileGeneratorNodeExtenderCookie = objectExtenders.RegisterExtenderProvider(extenderCatId, extenderName, _singleFileGeneratorNodeExtenderProvider, localizedName);
                }
            }
            finally
            {
                _initialized = true;
            }
        }
コード例 #2
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            base.InitializeAsync(cancellationToken, progress);

            try
            {
                // this block assumes that the ProjectPackage instances will all be initialized on the same thread,
                // but doesn't assume that only one ProjectPackage instance exists at a time
                if (Interlocked.Increment(ref _singleFileGeneratorNodeExtenderReferenceCount) == 1)
                {
                    ObjectExtenders objectExtenders = (ObjectExtenders)GetService(typeof(ObjectExtenders));
                    _singleFileGeneratorNodeExtenderProvider = new SingleFileGeneratorNodeExtenderProvider();
                    string extenderCatId = typeof(FileNodeProperties).GUID.ToString("B");
                    string extenderName  = SingleFileGeneratorNodeExtenderProvider.Name;
                    string localizedName = extenderName;
                    _singleFileGeneratorNodeExtenderCookie = objectExtenders.RegisterExtenderProvider(extenderCatId, extenderName, _singleFileGeneratorNodeExtenderProvider, localizedName);
                }
            }
            finally
            {
                _initialized = true;
            }
        }
コード例 #3
0
        protected override void Initialize()
        {
            base.Initialize();

            var serviceProvider = this.AsVsServiceProvider();

            // register the language service
            _languageInfo  = new AntlrLanguageInfo(this.AsVsServiceProvider());
            _languageInfo4 = new Antlr4LanguageInfo(this.AsVsServiceProvider());

            ((IServiceContainer)this).AddService(typeof(AntlrLanguageInfo), _languageInfo, true);
            ((IServiceContainer)this).AddService(typeof(Antlr4LanguageInfo), _languageInfo4, true);

            ObjectExtenders objectExtenders = (ObjectExtenders)GetService(typeof(ObjectExtenders));

            _grammarFileObjectExtenderProvider = new GrammarFileObjectExtenderProvider();
            string extenderCatId = Microsoft.VisualStudio.VSConstants.CATID.CSharpFileProperties_string;
            string extenderName  = GrammarFileObjectExtenderProvider.Name;
            string localizedName = GrammarFileObjectExtenderProvider.Name;

            _grammarFileObjectExtenderCookie = objectExtenders.RegisterExtenderProvider(extenderCatId, extenderName, _grammarFileObjectExtenderProvider, localizedName);

            IVsTrackProjectDocuments2 trackDocuments2 = serviceProvider.GetTrackProjectDocuments2();

            trackDocuments2.AdviseTrackProjectDocumentsEvents(this, out _trackDocumentsEventsCookie);
        }
コード例 #4
0
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <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 void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();
            this.RegisterProjectFactory(new NodejsUwpProjectFactory(this));

            // Register Extender to enable properties to filter the base project properties in the Property Window
            propertyExtender = (EnvDTE.ObjectExtenders)GetService(typeof(EnvDTE.ObjectExtenders));
            extenderCookie   = propertyExtender.RegisterExtenderProvider(GuidList.guidPropertyExtenderCATID.ToString("B"),
                                                                         NodejsUwpExtenderProvider.uwpExtenderName, new NodejsUwpExtenderProvider());
        }
コード例 #5
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()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            // Base initialize
            base.Initialize();

            // Register project factories
            try
            {
                this.RegisterProjectFactory(new Dot42ProjectFlavorFactory(this));
                Trace.WriteLine("Registered ObfuscationProjectFactory");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(string.Format("Error {0}: {1}\n{2}", ex.GetType().FullName,
                                                                   ex.Message, ex.StackTrace));
            }

#if INCLUDE_EDITOR
            // Register editor factories
            try
            {
                RegisterEditorFactory(new XmlEditorFactory(this));
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(string.Format("Error {0}: {1}\n{2}", ex.GetType().FullName, ex.Message, ex.StackTrace));
            }
#endif

            try
            {
                // Get DTE
                dte = (EnvDTE.DTE) this.GetService(typeof(EnvDTE.DTE));
                if (dte == null)
                {
                    throw new InvalidOperationException("EnvDTE.DTE not found");
                }
                dteVersion = dte.Version;

                // Get extender manager
                this.extensionMgr = (EnvDTE.ObjectExtenders)GetService(typeof(EnvDTE.ObjectExtenders));
                if (extensionMgr == null)
                {
                    throw new InvalidOperationException("ObjectExtenders not found");
                }

                foreach (string catid in ResourceExtender.CategoryIds)
                {
                    extenderCookies.Add(extensionMgr.RegisterExtenderProvider(catid, ResourceExtender.Name, new ResourceExtenderProvider(this), "Dot42 Resource Extender"));
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "ObjectExtender registration failed: {0}",
                                              ex.Message));
            }

            try
            {
                // Add our command handlers for menu (commands must exist in the .vsct file)
                var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
                if (null != mcs)
                {
                    // Create the command for the tool window
                    var logCatCommandId = new CommandID(GuidList.Guids.guidDot42ProjectCmdSet, (int)PkgCmdIds.cmdidLogCatTool);
                    var menuToolWin     = new MenuCommand(ShowLogCatWindow, logCatCommandId);
                    mcs.AddCommand(menuToolWin);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Menu initialization failed: {0}",
                                              ex.Message));
            }
        }
コード例 #6
0
ファイル: NodejsUwpPackage.cs プロジェクト: sramos30/ntvsiot
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <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 void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();
            this.RegisterProjectFactory(new NodejsUwpProjectFactory(this));

            // Register Extender to enable properties to filter the base project properties in the Property Window 
            propertyExtender = (EnvDTE.ObjectExtenders)GetService(typeof(EnvDTE.ObjectExtenders));
            extenderCookie = propertyExtender.RegisterExtenderProvider(GuidList.guidPropertyExtenderCATID.ToString("B"),
                                                                 NodejsUwpExtenderProvider.uwpExtenderName, new NodejsUwpExtenderProvider());
        }