예제 #1
0
        public override void Recalculate()
        {
            if (_isDismissed)
            {
                throw (new InvalidOperationException("Cannot recalculate.  The session is dismissed."));
            }

            // Clear out the active set of signatures.
            _activeSignatures.Clear();

            // In order to find the signatures to be displayed in this session, we'll need to go through each of the signature help
            // providers and ask them for signatures at the trigger point.

            List <ISignature> signatures = new List <ISignature>();

            foreach (ISignatureHelpSource provider in _componentContext.GetSignatureHelpSources(this))
            {
                provider.AugmentSignatureHelpSession(this, signatures);

                // The source could have done anything to the session.  Let's verify that we're still alive and well.
                if (this.IsDismissed)
                {
                    return;
                }
            }

            if (signatures != null)
            {
                _activeSignatures.AddRange(signatures);
            }

            // If we ended-up with zero signatures, that's it.  We need to dismiss and get out of here.
            if (_activeSignatures.Count == 0)
            {
                this.Dismiss();
                return;
            }

            // Let's determine which signature should be "selected" before we find a presenter.
            if (!_activeSignatures.Contains(_selectedSignature))
            {
                // The old selection is no longer valid (or we never had one).  Let's select the first signature.
                this.SelectedSignature = _activeSignatures[0];
            }

            // If we don't already have a presenter for this session, find one.
            if (base.presenter == null)
            {
                base.presenter = FindPresenter(this, _componentContext.OrderedIntellisensePresenterProviderExports, _componentContext.GuardedOperations);
                if (base.presenter != null)
                {
                    this.RaisePresenterChanged();
                }
                else
                {
                    this.Dismiss();
                    return;
                }
            }

            base.RaiseRecalculated();
        }