public BraceCompletionAggregator(BraceCompletionAggregatorFactory factory)
        {
            _factory = factory;

            Init();
        }
            // Create the session
            public bool TryCreate(BraceCompletionAggregatorFactory factory, ITextView textView, SnapshotPoint openingPoint, char openingBrace, out IBraceCompletionSession session)
            {
                char closingBrace = GetClosingBrace(Metadata, openingBrace);

                if (IsSession)
                {
                    bool created = false;
                    IBraceCompletionSession currentSession = null;

                    factory.GuardedOperations.CallExtensionPoint(() => {
                        created = _sessionPair.Value.TryCreateSession(textView, openingPoint, openingBrace, closingBrace, out currentSession);
                    });

                    if (created)
                    {
                        session = currentSession;
                        return(true);
                    }

                    session = null;
                    return(false);
                }
                else if (IsContext)
                {
                    // Get a language specific context and add it to a default session.
                    IBraceCompletionContext context = null;

                    // check AllowDefaultSession to avoid starting a new "" session next to a "
                    if (AllowDefaultSession(openingPoint, openingBrace, closingBrace))
                    {
                        bool created = false;

                        factory.GuardedOperations.CallExtensionPoint(() => {
                            created = _contextPair.Value.TryCreateContext(textView, openingPoint, openingBrace, closingBrace, out context);
                        });

                        if (created)
                        {
                            session = new BraceCompletionDefaultSession(textView, openingPoint.Snapshot.TextBuffer, openingPoint, openingBrace,
                                                                        closingBrace, factory.UndoManager, factory.EditorOperationsFactoryService, context);

                            return(true);
                        }
                    }

                    session = null;
                    return(false);
                }
                else if (IsDefault)
                {
                    // perform some basic checks on the buffer before going in
                    if (AllowDefaultSession(openingPoint, openingBrace, closingBrace))
                    {
                        session = new BraceCompletionDefaultSession(textView, openingPoint.Snapshot.TextBuffer, openingPoint, openingBrace,
                                                                    closingBrace, factory.UndoManager, factory.EditorOperationsFactoryService);

                        return(true);
                    }
                }

                session = null;
                return(false);
            }