コード例 #1
0
        private IWebFormsNode CodeBlockNodeBuilder(Match match)
        {
            var node = new WebFormsCodeBlockNode();
            attributesReader.ReadAttributes(match, node.Attributes);

            if (match.Groups["code"].Success)
            {
                node.Code = match.Groups["code"].Captures[0].Value;
            }

            var openingBracesCount = match.Value.Count(c => c == '{');
            var closingBracesCount = match.Value.Count(c => c == '}');
            var closingBraceFirst = match.Value.IndexOf('}') < match.Value.IndexOf('{');

            if (openingBracesCount > closingBracesCount)
            {
                node.BlockType = CodeBlockNodeType.Opening;
            }
            else if (openingBracesCount < closingBracesCount)
            {
                node.BlockType = CodeBlockNodeType.Closing;
            }
            else if (closingBraceFirst)
            {
                node.BlockType = CodeBlockNodeType.Continued;
            }

            return node;
        }
コード例 #2
0
        private IWebFormsNode CodeBlockNodeBuilder(Match match)
        {
            var node = new WebFormsCodeBlockNode();

            attributesReader.ReadAttributes(match, node.Attributes);

            if (match.Groups["code"].Success)
            {
                node.Code = match.Groups["code"].Captures[0].Value;
            }

            var openingBracesCount = match.Value.Count(c => c == '{');
            var closingBracesCount = match.Value.Count(c => c == '}');
            var closingBraceFirst  = match.Value.IndexOf('}') < match.Value.IndexOf('{');

            if (openingBracesCount > closingBracesCount)
            {
                node.BlockType = CodeBlockNodeType.Opening;
            }
            else if (openingBracesCount < closingBracesCount)
            {
                node.BlockType = CodeBlockNodeType.Closing;
            }
            else if (closingBraceFirst)
            {
                node.BlockType = CodeBlockNodeType.Continued;
            }

            return(node);
        }