/// <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); }
public void InitializeTest() { this.container = new UnityContainer(); this.container.RegisterInstance <ILogger>(new Logger()); this.mockWordDocument = TestHelper.CreateAndRegisterMock <IWordDocument>(this.container); this.mockWordTemplate = TestHelper.CreateAndRegisterMock <IWordTemplate>(this.container); this.mockWordApplication = TestHelper.CreateAndRegisterMock <IWordApplication>(this.container); this.mockWordApplication.Setup(app => app.ActiveDocument).Returns(this.mockWordDocument.Object); this.mockWordTemplate.Setup(template => template.EnumerateBuildingBlockCategories()).Returns(() => this.mockBuildingBlockCategories.ToArray()); // lambda used for return so latest list always returned rather than point in time state here this.sut = this.container.Resolve <TeamProjectTemplate>(); }
/// <summary> /// Displays a layout definition in a template. /// </summary> /// <param name="projectTemplate">The template containing the layout definition.</param> /// <param name="layoutName">The name of the layout to be displayed.</param> public void DisplayDefinition(ITeamProjectTemplate projectTemplate, string layoutName) { if (projectTemplate == null) { throw new ArgumentNullException("projectTemplate"); } this.document.DeleteAllContents(); LayoutInformation layout = GetLayout(projectTemplate, layoutName); if (layout != null) { this.DisplayDefinition(layout); } }
/// <summary> /// Initializes a new instance of the <see cref="WorkItemLayout"/> class. /// </summary> /// <param name="layoutInformation">The layout information the layout is based on.</param> /// <param name="teamProjectTemplate">The team project template to get the building blocks from.</param> public WorkItemLayout(LayoutInformation layoutInformation, ITeamProjectTemplate teamProjectTemplate) { if (layoutInformation == null) { throw new ArgumentNullException("layoutInformation"); } if (teamProjectTemplate == null) { throw new ArgumentNullException("teamProjectTemplate"); } this.layoutInformation = layoutInformation; this.teamProjectTemplate = teamProjectTemplate; }
/// <summary> /// Initializes a new instance of the <see cref="LayoutDefinitionFormatter"/> class. /// </summary> /// <param name="logger">The logger to be used for logging.</param> /// <param name="document">The word document in which the layout definitions are viewed and edited.</param> /// <param name="template">The team project template which contains the layout building blocks to be used.</param> public LayoutDefinitionFormatter(ILogger logger, IWordDocument document, ITeamProjectTemplate template) { this.logger = logger; this.document = document; this.template = template; }
/// <summary> /// Gets a layout from a template. /// </summary> /// <param name="projectTemplate">The template to get the layout from.</param> /// <param name="layoutName">The name of the layout to get.</param> /// <returns>The layout, <c>null</c> if not found.</returns> private static LayoutInformation GetLayout(ITeamProjectTemplate projectTemplate, string layoutName) { LayoutInformation layout = projectTemplate.Layouts.Where(li => li.Name == layoutName).SingleOrDefault(); return(layout); }
/// <summary> /// Initializes a new instance of the <see cref="TeamProjectDocument"/> class. /// </summary> /// <param name="container">The unity container to use.</param> /// <param name="template">The team project template that contains the layout information.</param> /// <param name="formatter">The formatter to be used to format work items.</param> /// <param name="layoutDefinitionFormatter">The layout definition formatter to be used to show and edit layout definitions in the document.</param> /// <param name="verifier">The verifier to be used to verify the document structure.</param> /// <param name="factory">The factory used to create other objects.</param> /// <remarks> /// the code requires the <paramref name="wordDocument"/> parameter to have this exact name because of the way Unity does parameter overrides. /// </remarks> public TeamProjectDocument(IUnityContainer container, ITeamProjectTemplate template, ITeamProjectDocumentFormatter formatter, ILayoutDefinitionFormatter layoutDefinitionFormatter, ITeamProjectDocumentVerifier verifier, IFactory factory) { if (template == null) { throw new ArgumentNullException("template"); } if (formatter == null) { throw new ArgumentNullException("formatter"); } if (layoutDefinitionFormatter == null) { throw new ArgumentNullException("layoutDefinitionFormatter"); } if (verifier == null) { throw new ArgumentNullException("verifier"); } if (factory == null) { throw new ArgumentNullException("factory"); } this.container = container; this.loaded = false; this.template = template; this.formatter = formatter; this.layoutDefinitionFormatter = layoutDefinitionFormatter; this.verifier = verifier; this.factory = factory; XNamespace nsp = Constants.ProjectInformationNamespace; this.projectXName = nsp + "Project"; this.collectionUriXName = "CollectionUri"; this.collectionIdXName = "CollectionId"; this.projectNameXName = "ProjectName"; XNamespace nsq = Constants.QueryNamespace; this.queriesAndLayoutsXName = nsq + "QueriesAndLayouts"; this.queryAndLayoutXName = nsq + "QueryAndLayout"; this.queryXName = nsq + "Query"; this.layoutNameXName = nsq + "LayoutName"; XNamespace nsw = Constants.WorkItemNamespace; this.workItemsXName = nsw + "WorkItems"; this.workItemXName = nsw + "WorkItem"; XNamespace nsqw = Constants.QueryWorkItemNamespace; this.queryWorkItemAssociationQueryXName = nsqw + "Query"; this.queryWorkItemAssociationIdXName = nsqw + "WorkItem"; this.workItemManager = new WorkItemManager(); this.queryWorkItems = new List <QueryWorkItems>(); ILogger logger = this.container.Resolve <ILogger>(); logger.Log(TraceEventType.Verbose, "Creating a new Team Project Document"); }
/// <summary> /// Initializes a new instance of the <see cref="LayoutPickerWizardPagePresenter"/> class. /// </summary> /// <param name="wizardView">The overall wizard view.</param> /// <param name="pageView">The view for this page.</param> /// <param name="template">The template used to provide the layouts.</param> public LayoutPickerWizardPagePresenter(IWorkItemQueryAndLayoutPickerWizardView wizardView, ILayoutPickerWizardPageView pageView, ITeamProjectTemplate template) : base(wizardView, pageView) { this.pageView = pageView; this.template = template; }
/// <summary> /// Sets the mock manager not to have any active system template. /// </summary> private void SetNoSystemTemplate() { ITeamProjectTemplate template = null; this.mockDocumentManager.Setup(manager => manager.SystemTemplate).Returns(template); }
/// <summary> /// Initializes a new instance of the <see cref="TeamProjectDocumentFormatter"/> class. /// </summary> /// <param name="wordDocument">The <see cref="IWordDocument"/> object to be used by the formatter.</param> /// <param name="teamProjectTemplate">The <see cref="ITeamProjectTemplate"/> object to be used by the formatter to get building block definitions.</param> /// <param name="logger">The object to be used for logging.</param> public TeamProjectDocumentFormatter(IWordDocument wordDocument, ITeamProjectTemplate teamProjectTemplate, ILogger logger) { this.wordDocument = wordDocument; this.teamProjectTemplate = teamProjectTemplate; this.logger = logger; }