Ejemplo n.º 1
0
        protected override async Task InitializeAsync(
            CancellationToken cancellationToken,
            IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress).ConfigureAwait(false);

            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            // Proffer the service.
            var serviceContainer = this as IAsyncServiceContainer;
            var langService      = new XSharpLanguageService();

            langService.SetSite(this);
            serviceContainer.AddService(typeof(XSharpLanguageService), (container, token, type) => Task.FromResult((object)langService), true);

            // Register a timer to call our language service during idle periods.
            if (mComponentID == 0 &&
                (await GetServiceAsync(typeof(SOleComponentManager)).ConfigureAwait(true) is IOleComponentManager xMgr))
            {
                var crinfo = new OLECRINFO
                {
                    cbSize            = (uint)Marshal.SizeOf(typeof(OLECRINFO)),
                    grfcrf            = (uint)(_OLECRF.olecrfNeedIdleTime | _OLECRF.olecrfNeedPeriodicIdleTime),
                    grfcadvf          = (uint)(_OLECADVF.olecadvfModal | _OLECADVF.olecadvfRedrawOff | _OLECADVF.olecadvfWarningsOff),
                    uIdleTimeInterval = 1000
                };

                xMgr.FRegisterComponent(this, new OLECRINFO[] { crinfo }, out mComponentID);
            }
        }
Ejemplo n.º 2
0
    /// 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.
    protected override void Initialize() {
      base.Initialize();
      // Proffer the service.
      var serviceContainer = this as IServiceContainer;
      var langService = new XSharpLanguageService();
      langService.SetSite(this);
      serviceContainer.AddService(typeof(XSharpLanguageService), langService, true);

      // Register a timer to call our language service during idle periods.
      var xMgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;
      if (mComponentID == 0 && xMgr != 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;
        xMgr.FRegisterComponent(this, crinfo, out mComponentID);
      }
    }
Ejemplo n.º 3
0
        /// 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.
        protected override void Initialize()
        {
            base.Initialize();
            // Proffer the service.
            var serviceContainer = this as IServiceContainer;
            var langService      = new XSharpLanguageService();

            langService.SetSite(this);
            serviceContainer.AddService(typeof(XSharpLanguageService), langService, true);

            // Register a timer to call our language service during idle periods.
            var xMgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;

            if (mComponentID == 0 && xMgr != 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;
                xMgr.FRegisterComponent(this, crinfo, out mComponentID);
            }
        }