/// <summary>
        /// Saves a layout definition to the template
        /// </summary>
        /// <param name="projectTemplate">The template to save the definitions to.</param>
        /// <param name="layoutName">The name of the layout to be saved.</param>
        public void SaveDefinition(ITeamProjectTemplate projectTemplate, string layoutName)
        {
            if (projectTemplate == null)
            {
                throw new ArgumentNullException("projectTemplate");
            }

            if (string.IsNullOrEmpty(layoutName))
            {
                throw new ArgumentNullException("layoutName");
            }

            this.logger.Log(TraceEventType.Information, "Saving the layout definition {0} in the document to the template.", layoutName);
            projectTemplate.DeleteLayout(layoutName);

            string    block        = null;
            Paragraph startOfBlock = null;
            Paragraph previous     = null;

            List <BuildingBlockDefinition> blockDefinitions = new List <BuildingBlockDefinition>();

            block = null;
            this.logger.Log(TraceEventType.Verbose, "Total paragraphs is {0}", this.document.Paragraphs.Count());
            foreach (Paragraph p in this.document.Paragraphs)
            {
                if (this.ParagraphIsOfStyle(p, Constants.WorkItemDefinitionStyleName))
                {
                    if (startOfBlock != null)
                    {
                        AddBuildingBlockDefinition(blockDefinitions, block, startOfBlock, previous, false);
                    }

                    this.StartNewBlock(ref block, ref startOfBlock, p);
                }
                else if (startOfBlock == null && !string.IsNullOrEmpty(block))
                {
                    startOfBlock = p;
                }

                previous = p;
            }

            if (startOfBlock != null)
            {
                AddBuildingBlockDefinition(blockDefinitions, block, startOfBlock, previous, true);
            }

            projectTemplate.CreateLayout(layoutName, blockDefinitions);
        }