WebMarkupMin.Core.Parsers.HtmlParser.ParseEndIfConditionalComment C# (CSharp) Method

ParseEndIfConditionalComment() private method

Parses a End If conditional comment
private ParseEndIfConditionalComment ( HtmlConditionalCommentType type ) : void
type HtmlConditionalCommentType Conditional comment type
return void
        private void ParseEndIfConditionalComment(HtmlConditionalCommentType type)
        {
            if (_conditionalCommentStack.Count > 0)
            {
                var stackedConditionalComment = _conditionalCommentStack.Pop();
                var stackedType = stackedConditionalComment.Type;

                if (type == HtmlConditionalCommentType.Hidden || type == HtmlConditionalCommentType.Revealed)
                {
                    if (stackedType == type)
                    {
                        _conditionalCommentOpened = false;
                    }
                    else
                    {
                        throw new MarkupParsingException(
                            Strings.ErrorMessage_InvalidEndIfConditionalComment,
                            _innerContext.NodeCoordinates, _innerContext.GetSourceFragment());
                    }
                }
                else if (type == HtmlConditionalCommentType.RevealedValidating
                    || type == HtmlConditionalCommentType.RevealedValidatingSimplified)
                {
                    if (stackedType != HtmlConditionalCommentType.RevealedValidating
                        && stackedType != HtmlConditionalCommentType.RevealedValidatingSimplified)
                    {
                        throw new MarkupParsingException(
                            Strings.ErrorMessage_InvalidEndIfConditionalComment,
                            _innerContext.NodeCoordinates, _innerContext.GetSourceFragment());
                    }
                }
            }
            else
            {
                throw new MarkupParsingException(
                    Strings.ErrorMessage_IfConditionalCommentNotDeclared,
                    _innerContext.NodeCoordinates, _innerContext.GetSourceFragment());
            }

            if (_handlers.EndIfConditionalComment != null)
            {
                _handlers.EndIfConditionalComment(_context, type);
            }
        }