Пример #1
0
        public BuildLogPipeGenerator(IServiceProvider serviceProvider)
        {
            // Initialize the solution listener that will set XenkoVSBuilderMonitorGuid for this instance of VisualStudio.
            solutionEventsListener = new SolutionEventsListener(serviceProvider);
            solutionEventsListener.AfterProjectOpened += OnProjectOpened;

            // Process already opened projects
            var solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            if (solution != null)
            {
                IEnumHierarchies enumerator;
                var guid = Guid.Empty;
                var hierarchy = new IVsHierarchy[1] { null };
                uint fetched = 0;

                solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref guid, out enumerator);
                for (enumerator.Reset(); enumerator.Next(1, hierarchy, out fetched) == VSConstants.S_OK && fetched == 1; )
                {
                    OnProjectOpened(hierarchy[0]);
                }
            }
        }
Пример #2
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 void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString()));
            base.Initialize();

            IDEBuildLogger.UserRegistryRoot = UserRegistryRoot;

            solutionEventsListener = new SolutionEventsListener(this);
            solutionEventsListener.AfterSolutionBackgroundLoadComplete += solutionEventsListener_AfterSolutionBackgroundLoadComplete;
            solutionEventsListener.AfterActiveConfigurationChange += SolutionEventsListener_AfterActiveConfigurationChange;
            solutionEventsListener.StartupProjectChanged += SolutionEventsListener_OnStartupProjectChanged;

            dte2 = GetGlobalService(typeof(SDTE)) as DTE2;

            // Register the C# language service
            var serviceContainer = this as IServiceContainer;
            errorListProvider = new ErrorListProvider(this)
            {
                ProviderGuid = new Guid("ad1083c5-32ad-403d-af3d-32fee7abbdf1"),
                ProviderName = "Xenko Shading Language"
            };
            var langService = new NShaderLanguageService(errorListProvider);
            langService.SetSite(this);
            langService.InitializeColors(); // Make sure to initialize colors before registering!
            serviceContainer.AddService(typeof(NShaderLanguageService), langService, true);

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                XenkoCommands.ServiceProvider = this;
                XenkoCommands.RegisterCommands(mcs);
            }

            // Register a timer to call our language service during
            // idle periods.
            var mgr = GetService(typeof(SOleComponentManager))
                                       as IOleComponentManager;
            if (m_componentID == 0 && mgr != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
                                              (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
                                              (uint)_OLECADVF.olecadvfRedrawOff |
                                              (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out m_componentID);
            }
        }