Exemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_trackDocumentsEventsCookie != 0)
                {
                    var serviceProvider = this.AsVsServiceProvider();
                    IVsTrackProjectDocuments2 trackDocuments = serviceProvider.GetTrackProjectDocuments2();
                    trackDocuments.UnadviseTrackProjectDocumentsEvents(_trackDocumentsEventsCookie);
                    _trackDocumentsEventsCookie = 0;
                }

                if (_grammarFileObjectExtenderCookie != 0)
                {
                    ObjectExtenders objectExtenders = (ObjectExtenders)GetService(typeof(ObjectExtenders));
                    objectExtenders.UnregisterExtenderProvider(_grammarFileObjectExtenderCookie);
                    _grammarFileObjectExtenderCookie = 0;
                }

                if (_languageInfo != null)
                {
                    _languageInfo.Dispose();
                    _languageInfo = null;
                }

                if (_languageInfo4 != null)
                {
                    _languageInfo4.Dispose();
                    _languageInfo4 = null;
                }
            }

            base.Dispose(disposing);
        }
Exemplo n.º 2
0
        public object ExtenderNames()
        {
            EnvDTE.ObjectExtenders extenderService = (EnvDTE.ObjectExtenders) this.HierarchyNode.GetService(typeof(EnvDTE.ObjectExtenders));
            Utilities.CheckNotNull(extenderService, "Could not get the ObjectExtenders object from the services exposed by this property object");

            return(extenderService.GetExtenderNames(this.ExtenderCATID, this));
        }
Exemplo n.º 3
0
        protected override void Dispose(bool disposing)
        {
            // Unadvise solution listeners.
            try
            {
                if (disposing)
                {
                    // only decrement the reference count once, regardless of the number of times Dispose is called.
                    // Ignore if Initialize was never called.
                    if (_initialized && !_disposed && Interlocked.Decrement(ref _singleFileGeneratorNodeExtenderReferenceCount) == 0)
                    {
                        ObjectExtenders objectExtenders = (ObjectExtenders)GetService(typeof(ObjectExtenders));
                        objectExtenders.UnregisterExtenderProvider(_singleFileGeneratorNodeExtenderCookie);
                    }

                    foreach (SolutionListener solutionListener in this.solutionListeners)
                    {
                        solutionListener.Dispose();
                    }
                }
            }
            finally
            {
                _disposed = true;
                base.Dispose(disposing);
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
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;
            }
        }
Exemplo n.º 7
0
 public object Extender(string extenderName)
 {
     EnvDTE.ObjectExtenders extenderService = (EnvDTE.ObjectExtenders) this.Node.GetService(typeof(EnvDTE.ObjectExtenders));
     Debug.Assert(extenderService != null, "Could not get the ObjectExtenders object from the services exposed by this property object");
     Utilities.CheckNotNull(extenderService);
     return(extenderService.GetExtender(this.ExtenderCATID, extenderName, this));
 }
Exemplo n.º 8
0
 public object get_Extender(string extenderName)
 {
     EnvDTE.ObjectExtenders extenderService = (EnvDTE.ObjectExtenders)projectConfig.ProjectMgr.GetService(typeof(EnvDTE.ObjectExtenders));
     if (extenderService == null)
     {
         throw new InvalidOperationException();
     }
     return(extenderService.GetExtender(this.ExtenderCATID, extenderName, projectConfig));
 }
Exemplo n.º 9
0
 public object Extender(string extenderName)
 {
     EnvDTE.ObjectExtenders extenderService = (EnvDTE.ObjectExtenders) this.Node.GetService(typeof(EnvDTE.ObjectExtenders));
     Debug.Assert(extenderService != null, "Could not get the ObjectExtenders object from the services exposed by this property object");
     if (extenderService == null)
     {
         throw new InvalidOperationException();
     }
     return(extenderService.GetExtender(this.ExtenderCATID, extenderName, this));
 }
Exemplo n.º 10
0
        /// <include file='doc\Automation.uex' path='docs/doc[@for="OAProjectItem.get_Extender"]/*' />
        public virtual object get_Extender(string ExtenderName)
        {
            EnvDTE.ObjectExtenders extenderManager = (EnvDTE.ObjectExtenders) this.project.project.Site.GetService(typeof(EnvDTE.ObjectExtenders));
            if (extenderManager == null)
            {
                throw new Exception(SR.GetString(SR.FailedToGetService));
            }

            return(extenderManager.GetExtender(this.ExtenderCATID, ExtenderName, this));
        }
Exemplo n.º 11
0
 public object ExtenderNames()
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     EnvDTE.ObjectExtenders extenderService = (EnvDTE.ObjectExtenders) this.Node.GetService(typeof(EnvDTE.ObjectExtenders));
     Debug.Assert(extenderService != null, "Could not get the ObjectExtenders object from the services exposed by this property object");
     if (extenderService == null)
     {
         throw new InvalidOperationException();
     }
     return(extenderService.GetExtenderNames(this.ExtenderCATID, this));
 }
Exemplo n.º 12
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());
        }
Exemplo n.º 13
0
 public object Extender(string extenderName)
 {
     EnvDTE.ObjectExtenders extenderService = (EnvDTE.ObjectExtenders) this.Node.GetService(typeof(EnvDTE.ObjectExtenders));
     return(extenderService.GetExtender(this.ExtenderCATID(), extenderName, this));
 }
 public object get_Extender(string extenderName)
 {
     EnvDTE.ObjectExtenders extenderService = (EnvDTE.ObjectExtenders) this.ProjectMgr.GetService(typeof(EnvDTE.ObjectExtenders));
     return(extenderService.GetExtender(this.ExtenderCATID, extenderName, this));
 }
Exemplo n.º 15
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));
            }
        }
Exemplo n.º 16
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());
        }