Beispiel #1
0
        private void ParseDirective([NotNull] CompositeElement parentElement)
        {
            var directive = new T4Directive();

            // appends the directive start token (<#@)
            AppendNewChild(directive, T4TokenNodeTypes.DirectiveStart);
            Advance();

            // builds the directive (name and attributes)
            var             directiveBuilder = new DirectiveBuilder(this);
            T4TokenNodeType tokenType        = GetTokenType();

            while (tokenType != null && !tokenType.IsTag)
            {
                if (tokenType == T4TokenNodeTypes.Name)
                {
                    directiveBuilder.AddName();
                }
                else if (tokenType == T4TokenNodeTypes.Equal)
                {
                    directiveBuilder.AddEqual();
                }
                else if (tokenType == T4TokenNodeTypes.Quote)
                {
                    directiveBuilder.AddQuote();
                }
                else if (tokenType == T4TokenNodeTypes.Value)
                {
                    directiveBuilder.AddValue();
                }
                tokenType = Advance();
            }
            directiveBuilder.Finish(directive);

            // appends the block end token if available
            if (tokenType == T4TokenNodeTypes.BlockEnd)
            {
                AppendNewChild(directive, T4TokenNodeTypes.BlockEnd);
                Advance();
            }
            else
            {
                AppendMissingToken(directive, MissingTokenType.BlockEnd);
                if (_notClosedDirectives == null)
                {
                    _notClosedDirectives = new List <T4Directive>();
                }
                _notClosedDirectives.Add(directive);
            }

            AppendNewChild(parentElement, directive);

            // checks if we're including a file
            if (directive.IsSpecificDirective(_directiveInfoManager.Include))
            {
                HandleIncludeDirective(directive, parentElement);
            }
        }
Beispiel #2
0
        public IT4DirectiveAttribute CreateDirectiveAttribute([CanBeNull] string name, [CanBeNull] string value)
        {
            T4Directive directive = CreateDirective("dummy", Pair.Of(name, value));

            return(directive.GetAttributes().First());
        }