protected BabelPackage() { ServiceCreatorCallback callback = new ServiceCreatorCallback( delegate(IServiceContainer container, Type serviceType) { if (typeof(Babel.HLSLLanguageService) == serviceType) { Babel.HLSLLanguageService language = new Babel.HLSLLanguageService(); language.SetSite(this); // register for idle time callbacks IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager; if (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 componentID); } return language; } else { return null; } }); // proffer the LanguageService (this as IServiceContainer).AddService(typeof(Babel.HLSLLanguageService), callback, true); }
/// <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(); _languageService = new Babel.HLSLLanguageService(); _languageService.SetSite(this); IServiceContainer serviceContainer = (IServiceContainer)this; serviceContainer.AddService(typeof(Babel.HLSLLanguageService), _languageService, true); _languageService.Preferences.ParameterInformation = true; IOleComponentManager componentManager = (IOleComponentManager)this.GetService(typeof(SOleComponentManager)); if (componentID == 0 && componentManager != 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; componentManager.FRegisterComponent(this, crinfo, out componentID); } }