Ejemplo n.º 1
0
        /// <summary>Adds a new statement block.</summary>
        /// <param name="statementBlock">The statement block to add.</param>
        /// <returns>A new instance of <see cref="T4StatementBlock"/>, representing <paramref name="statementBlock"/> in the T4 file.</returns>
        public T4StatementBlock AddStatementBlock(T4StatementBlock statementBlock)
        {
            T4StatementBlock anchor = GetStatementBlocks().LastOrDefault();

            using (WriteLockCookie.Create(IsPhysical())) {
                return(anchor == null
                                        ? ModificationUtil.AddChild(this, statementBlock)
                                        : ModificationUtil.AddChildAfter(anchor, statementBlock));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a new statement block.
        /// </summary>
        /// <param name="statementBlock">The statement block to add.</param>
        /// <returns>A new instance of <see cref="T4StatementBlock"/>, representing <paramref name="statementBlock"/> in the T4 file.</returns>
        public T4StatementBlock AddStatementBlock(T4StatementBlock statementBlock)
        {
            if (statementBlock == null)
            {
                throw new ArgumentNullException("statementBlock");
            }

            T4StatementBlock anchor = GetStatementBlocks().LastOrDefault();

            using (this.CreateWriteLock()) {
                return(anchor == null
                                        ? ModificationUtil.AddChild(this, statementBlock)
                                        : ModificationUtil.AddChildAfter(anchor, statementBlock));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a new statement block.
        /// </summary>
        /// <param name="statementBlock">The statement block to add.</param>
        /// <returns>A new instance of <see cref="T4StatementBlock"/>, representing <paramref name="statementBlock"/> in the T4 file.</returns>
        public T4StatementBlock AddStatementBlock(T4StatementBlock statementBlock)
        {
            if (statementBlock == null)
                throw new ArgumentNullException("statementBlock");

            T4StatementBlock anchor = GetStatementBlocks().LastOrDefault();
            using (this.CreateWriteLock()) {
                return anchor == null
                    ? ModificationUtil.AddChild(this, statementBlock)
                    : ModificationUtil.AddChildAfter(anchor, statementBlock);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Checks if the current token represents the beginning of a code block, if yes, parse every code block after the token.
        /// </summary>
        /// <param name="tokenNodeType">The current token type.</param>
        /// <param name="parentElement">The parent element where the potential code block will be appended as a child.</param>
        /// <returns><c>true</c> is a code block has been parsed, <c>false</c> otherwise.</returns>
        private bool TryParseCodeBlock([CanBeNull] T4TokenNodeType tokenNodeType, [NotNull] CompositeElement parentElement)
        {
            if (tokenNodeType != null) {

                T4CodeBlock codeBlock;
                if (tokenNodeType == T4TokenNodeTypes.StatementStart)
                    codeBlock = new T4StatementBlock();
                else if (tokenNodeType == T4TokenNodeTypes.ExpressionStart)
                    codeBlock = new T4ExpressionBlock();
                else if (tokenNodeType == T4TokenNodeTypes.FeatureStart)
                    codeBlock = new T4FeatureBlock();
                else
                    codeBlock = null;

                if (codeBlock != null) {
                    AppendNewChild(parentElement, ParseCodeBlock(tokenNodeType, codeBlock));
                    return true;
                }

            }
            return false;
        }