コード例 #1
0
            /// <summary>
            /// Finishes building the directive by appending its name and all attributes.
            /// </summary>
            /// <param name="parent">The directive.</param>
            internal void Finish([NotNull] CompositeElement parent)
            {
                if (_firstInfo == null)
                {
                    _treeBuilder.AppendMissingToken(parent, MissingTokenType.DirectiveName);
                    return;
                }

                AttributeInfo attrInfo;

                if (_firstInfo.HasNameOnly)
                {
                    _treeBuilder.AppendNewChild(parent, _firstInfo.NameToken);
                    attrInfo = _firstInfo.Next;
                }
                else
                {
                    attrInfo = _firstInfo;
                    _treeBuilder.AppendMissingToken(parent, MissingTokenType.DirectiveName);
                }

                while (attrInfo != null)
                {
                    _treeBuilder.AppendNewChild(parent, attrInfo.ToAttribute());
                    attrInfo = attrInfo.Next;
                }
            }
コード例 #2
0
                internal T4DirectiveAttribute ToAttribute()
                {
                    var attribute = new T4DirectiveAttribute();

                    if (NameToken != null)
                    {
                        _builder.AppendNewChild(attribute, NameToken);
                        if (EqualToken != null)
                        {
                            _builder.AppendNewChild(attribute, EqualToken);
                        }
                        else
                        {
                            if (OpeningQuoteToken == null)
                            {
                                Assertion.Assert(ValueToken == null, "ValueToken should be null if there's no opening quote.");
                                Assertion.Assert(ClosingQuoteToken == null, "ClosingQuoteToken should be null if there's no opening quote.");
                                _builder.AppendMissingToken(attribute, MissingTokenType.EqualSignAndAttributeValue);
                                return(attribute);
                            }
                            _builder.AppendMissingToken(attribute, MissingTokenType.EqualSign);
                        }
                    }
                    else if (EqualToken != null)
                    {
                        _builder.AppendMissingToken(attribute, MissingTokenType.AttributeName);
                        _builder.AppendNewChild(attribute, EqualToken);
                    }
                    else
                    {
                        _builder.AppendMissingToken(attribute, MissingTokenType.AttributeNameAndEqualSign);
                    }

                    if (OpeningQuoteToken == null)
                    {
                        Assertion.Assert(ValueToken == null, "ValueToken should be null if there's no opening quote.");
                        Assertion.Assert(ClosingQuoteToken == null, "ClosingQuoteToken should be null if there's no opening quote.");
                        _builder.AppendMissingToken(attribute, MissingTokenType.AttributeValue);
                        return(attribute);
                    }

                    _builder.AppendNewChild(attribute, OpeningQuoteToken);
                    if (ValueToken != null)
                    {
                        _builder.AppendNewChild(attribute, ValueToken);
                    }
                    if (ClosingQuoteToken != null)
                    {
                        _builder.AppendNewChild(attribute, ClosingQuoteToken);
                    }
                    else
                    {
                        _builder.AppendMissingToken(attribute, MissingTokenType.Quote);
                    }

                    return(attribute);
                }