protected override void PrintPreview(ToolStripButton sender) { Model.Info_tmp info = this.ucTmpList1.CurrentSelectValue as Model.Info_tmp; if (info == null || info.Parts.Count == 0) { return; } DocBuilder docBuilder = new DocBuilder(info); DocBuilder.PrintDocPreview(docBuilder.ToStream(), Doc.DocBuilder.ReportName); //Aspose.Words.Document doc = new Aspose.Words.Document(docBuilder.ToStream()); ////Aspose.Words.Rendering.AsposeWordsPrintDocument printDocument = new Aspose.Words.Rendering.AsposeWordsPrintDocument(doc); //using (System.Drawing.Printing.PrintDocument printDoc = Miles.Coro.Common.Print.PrintConfigManager.ApplyPrintSettings(new Aspose.Words.Rendering.AsposeWordsPrintDocument(doc), Doc.DocBuilder.ReportName)) //{ // PrintPreviewDialog previewDlg = new PrintPreviewDialog(); // previewDlg.Document = printDoc; // previewDlg.ShowInTaskbar = true; // previewDlg.MinimizeBox = true; // previewDlg.PrintPreviewControl.Zoom = 1.5d; // previewDlg.WindowState = FormWindowState.Maximized; // previewDlg.ShowDialog(); //} }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 3); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } DocBuilder.AddContentLine(ref _flowDocument, "Station Type", new DocContentItem(_stationOrigin, 15, "Table 1-4: Derelict Station Origins")); DocBuilder.AddContentLine(ref _flowDocument, "Armour", new DocContentItem(Armour.ToString(CultureInfo.InvariantCulture), 15, "Derelict Station")); DocBuilder.AddContentLine(ref _flowDocument, "Hull Integrity", new DocContentItem(_hullIntegrity.ToString(CultureInfo.InvariantCulture), 15, "Derelict Station")); if (_resourceArcheotechCache > 0) { DocBuilder.AddContentLine(ref _flowDocument, "Archeotech Resources", new DocContentItem(ResourceArcheotechCacheText)); } if (_resourceXenosRuins > 0) { DocBuilder.AddContentLine(ref _flowDocument, "Xenotech Resources", new DocContentItem(ResourceXenosRuinsText)); } if (_resourceArcheotechCache == 0 && _resourceXenosRuins == 0) { DocBuilder.AddContentLine(ref _flowDocument, "Resources", new DocContentItem("None")); } if (_inhabitants != Species.None) { DocBuilder.AddContentLine(ref _flowDocument, "Inhabitants", new DocContentItem(GetSpeciesText(_inhabitants))); DocBuilder.AddContentLine(ref _flowDocument, "Inhabitant Development", _inhabitantDevelopment); } }
public override ICollection <OverloadDoc> GetOverloads(object value) { if (value is BuiltinFunction bf) { return(GetBuiltinFunctionOverloads(bf)); } if (value is BuiltinMethodDescriptor bmd) { return(GetBuiltinFunctionOverloads(bmd.Template)); } if (value is PythonFunction pf) { return(new[] { new OverloadDoc( pf.__name__, pf.__doc__ as string, GetParameterDocs(pf) ) }); } if (value is Method method) { return(GetOverloads(method.__func__)); } if (value is Delegate dlg) { return(new[] { DocBuilder.GetOverloadDoc(dlg.GetType().GetMethod("Invoke"), dlg.GetType().Name, 0, false) }); } return(new OverloadDoc[0]); }
internal static string GetDocumentation(Type type) { // Python documentation object[] docAttr = type.GetCustomAttributes(typeof(DocumentationAttribute), false); if (docAttr != null && docAttr.Length > 0) { return(((DocumentationAttribute)docAttr[0]).Documentation); } if (type == typeof(DynamicNull)) { return(null); } // Auto Doc (XML or otherwise) string autoDoc = DocBuilder.CreateAutoDoc(type); if (autoDoc == null) { autoDoc = String.Empty; } else { autoDoc += Environment.NewLine + Environment.NewLine; } // Simple generated helpbased on ctor, if available. ConstructorInfo[] cis = type.GetConstructors(); foreach (ConstructorInfo ci in cis) { autoDoc += FixCtorDoc(type, DocBuilder.CreateAutoDoc(ci, DynamicHelpers.GetPythonTypeFromType(type).Name, 0)) + Environment.NewLine; } return(autoDoc); }
public void Export(SDProject sdProject, string outputPath) { _sdProject = sdProject; _outputPath = outputPath; _docCount = sdProject.DocumentationLanguages.Count; _docIndex = 0; foreach (var docLanguage in sdProject.DocumentationLanguages) { var currentOutputPath = Path.Combine(outputPath, docLanguage); _currentDocLanguage = docLanguage; ExecuteOnStepMessage(_wordStrings.LoadingTemplate); ExecuteOnStepProgress(10); var docBuilder = new DocBuilder(_sdProject, _localController.GetLocalStringsOrDefault <WordStrings>(_currentDocLanguage), _currentDocLanguage, currentOutputPath); ExecuteOnStepProgress(20); ExecuteOnStepMessage(_wordStrings.CreatingDocument); docBuilder.BuildDocument(); ExecuteOnStepProgress(80); ExecuteOnStepMessage(_wordStrings.SavingDocument); docBuilder.SaveToOutputFolder(); ExecuteOnStepProgress(90); ExecuteOnStepMessage(_wordStrings.DeleteTmp); Directory.Delete(Path.Combine(_outputPath, _currentDocLanguage, "tmp"), true); _docIndex++; } }
private static void Excute(string args) { args = args.Replace("\\", "\\\\"); try { CmdParameter cmdParameter = CmdParameter.Create(args); if (string.IsNullOrEmpty(cmdParameter.inDir)) { return; } if (!string.IsNullOrEmpty(cmdParameter.docDir)) { DocBuilder docBuilder = new DocBuilder(cmdParameter); docBuilder.Excute(); } if (!string.IsNullOrEmpty(cmdParameter.outDir)) { CompressBuilder compressor = new CompressBuilder(cmdParameter); compressor.Excute(); } } catch (Exception ex) { Console.WriteLine(string.Format("error:\"{0}\".", ex.Message)); } }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 3); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } DocBuilder.AddContentLine(ref _flowDocument, "Type", new DocContentItem("Gas Giant")); DocBuilder.AddContentLine(ref _flowDocument, "Body", new DocContentItem(_body, 19, "Table 1-6: Body")); DocBuilder.AddContentLine(ref _flowDocument, "Gravity", new DocContentItem(_gravity, 20, "Table 1-7: Gravity")); if (_planetaryRingsDebris == 1) { DocBuilder.AddContentLine(ref _flowDocument, "Planetary Rings (Debris)", new DocContentItem("No additional penalty to required Pilot Test when passing through the Rings", 20, "Table 1-8: Orbital Features")); } else if (_planetaryRingsDebris > 1) { int multiplier = _planetaryRingsDebris - 1; int penalty = -10 * multiplier; DocBuilder.AddContentLine(ref _flowDocument, "Planetary Rings (Debris)", new DocContentItem(penalty + " penalty to required Pilot Test when passing through the Rings", 20, "Table 1-8: Orbital Features")); } if (_planetaryRingsDust > 0) { int multiplier = _planetaryRingsDust - 1; int penalty = (-5 * multiplier) - 20; DocBuilder.AddContentLine(ref _flowDocument, "Planetary Rings (Dust)", new DocContentItem(penalty + " penalty to use augers through or within the Rings", 20, "Table 1-8: Orbital Features")); } if (_inhabitants != Species.None) { DocBuilder.AddContentLine(ref _flowDocument, "Inhabitants", new DocContentItem(GetSpeciesText(_inhabitants))); DocBuilder.AddContentLine(ref _flowDocument, "Inhabitant Development", _inhabitantDevelopment); } }
public void ValiDoc_WithSingleRuleValidator_OutputSingleRule() { var validator = new SingleRuleValidator(); var ruleGenerator = new DocBuilder(new RuleDescriptionBuilder(new ValidatorErrorMessageBuilder(new FluentValidationHelpers()))); var validationRules = ruleGenerator.Document(validator).ToList(); var expectedOutput = new List <RuleDescriptor> { new RuleDescriptor { MemberName = "First Name", Rules = new List <RuleDescription> { new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotEmptyValidator", ValidationMessage = "'First Name' should not be empty." } } } }; validationRules.Should().HaveCount(1); validationRules.ShouldBeEquivalentTo(expectedOutput, options => options.WithStrictOrdering()); }
public void DocBuilder_WithValidator_ReturnsRuleDescription() { var singleRuleValidator = new SingleRuleValidator(); var expectedRuleDescription = new RuleDescriptor { MemberName = "First Name", Rules = new List <RuleDescription> { new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidationMessage = "Mock message", ValidatorName = "NotEmptyValidator" } } }; var mockRuleDescriptor = new Mock <IRuleBuilder>(); mockRuleDescriptor.Setup(x => x.BuildRuleDescription(It.IsAny <IEnumerable <IPropertyValidator> >(), It.IsAny <string>(), It.IsAny <CascadeMode>(), It.IsAny <PropertyRule>())).Returns(expectedRuleDescription); var docBuilder = new DocBuilder(mockRuleDescriptor.Object); var actualResult = docBuilder.Document(singleRuleValidator).ToList(); actualResult.Should().HaveCount(1); actualResult.Should().BeEquivalentTo(expectedRuleDescription); }
public void DocBuilder_WithNoRuleValidator_ReturnEmptyOutput() { var docBuilder = new DocBuilder(Mock.Of <IRuleBuilder>()); var actualOutput = docBuilder.Document(new NoRulesValidator()); actualOutput.Should().BeEquivalentTo(Enumerable.Empty <RuleDescription>()); }
public void DocBuilder_WithNullValidator_ThrowsArgumentNullException() { var docBuilder = new DocBuilder(Mock.Of <IRuleBuilder>()); var thrownException = Record.Exception(() => docBuilder.Document <AbstractValidator <Address> >(null).ToList()); //.ToList() to materialise exception thrownException.Should().BeOfType <ArgumentNullException>().Which.ParamName.Should().Be("validator"); }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, _ship.ShipName, 3); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } DocBuilder.AddContentLine(ref _flowDocument, "Species", new DocContentItem(Globals.GetSpeciesString(_ship.Race))); DocBuilder.AddContentLine(ref _flowDocument, "Ship Type", new DocContentItem(_ship.ShipName, _ship.PageNumber, "", _ship.BookSource)); DocBuilder.AddContentLine(ref _flowDocument, "Ship Class", StarshipTools.GetShipClassDoc(_ship.ShipClass)); if (_ship.Race == Species.Human && _ship.ShipName != "Wolfpack Raider") { DocBuilder.AddContentLine(ref _flowDocument, "Power", new DocContentItem(_ship.UsedPower + " / " + _ship.TotalPower)); DocBuilder.AddContentLine(ref _flowDocument, "Space", new DocContentItem(_ship.UsedSpace + " / " + _ship.TotalSpace)); if (_ship.EssentialComponents.Count > 0) { List <DocContentItem> items = _ship.EssentialComponents.Select(component => new DocContentItem(component.ComponentName, component.PageNumber, "", component.BookSource)).ToList(); DocBuilder.AddContentList(ref _flowDocument, "Essential Components", items); } else { DocBuilder.AddContentLine(ref _flowDocument, "Essential Components", new DocContentItem("None")); } if (_ship.SupplementalComponents.Count > 0) { List <DocContentItem> items = _ship.SupplementalComponents.Select(component => new DocContentItem(component.ComponentName, component.PageNumber, "", component.BookSource)).ToList(); DocBuilder.AddContentList(ref _flowDocument, "Supplemental Components", items); } else { DocBuilder.AddContentLine(ref _flowDocument, "Supplemental Components", new DocContentItem("None")); } if (_ship.WeaponComponents.Count > 0) { List <DocContentItem> items = _ship.WeaponComponents.Select(component => new DocContentItem(component.MountSlot + ": " + component.ComponentName, component.PageNumber, "", component.BookSource)).ToList(); DocBuilder.AddContentList(ref _flowDocument, "Weapon Components", items); } else { DocBuilder.AddContentLine(ref _flowDocument, "Essential Components", new DocContentItem("None")); } } else if (_ship.Race == Species.Ork) { if (_ship.OrkUpgrades.Count > 0) { List <DocContentItem> items = _ship.OrkUpgrades.Select(upgrade => new DocContentItem(upgrade)).ToList(); DocBuilder.AddContentList(ref _flowDocument, "Orky Ship Modifications", items); } else { DocBuilder.AddContentLine(ref _flowDocument, "Orky Ship Modifications", new DocContentItem("None")); } } }
public void ValiDoc_WithMultipleRuleValidator_OutputMultipleRulesWithValidationMessage() { var validator = new MultipleRuleValidator(); var ruleGenerator = new DocBuilder(new RuleDescriptionBuilder(new ValidatorErrorMessageBuilder(new FluentValidationHelpers()))); var validationRules = ruleGenerator.Document(validator).ToList(); var expectedOutput = new List <RuleDescriptor> { new RuleDescriptor { MemberName = "First Name", Rules = new List <RuleDescription> { new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotNullValidator", ValidationMessage = "'First Name' must not be empty." } } }, new RuleDescriptor { MemberName = "Last Name", Rules = new List <RuleDescription> { new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotEmptyValidator", ValidationMessage = "'Last Name' should not be empty." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "MinimumLengthValidator", ValidationMessage = "'Last Name' must be more than {MinLength} characters. You entered {TotalLength} characters." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "MaximumLengthValidator", ValidationMessage = "'Last Name' must be less than {MaxLength} characters. You entered {TotalLength} characters." } } } }; validationRules.Should().HaveCount(2); validationRules.ShouldBeEquivalentTo(expectedOutput, options => options.WithStrictOrdering()); }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 3); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } DocBuilder.AddContentLine(ref _flowDocument, "", new DocContentItem("Dust Clouds follow the rules for Nebulae on page 227 of the Rogue Trader Core Rulebook. ", 15, "Dust Cloud")); }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 2); DocBuilder.AddContentLine(ref _flowDocument, "System Influence", new DocContentItem(GetZoneSizeString(), 13, "Table 1-2: Star Generation")); if (Children.Count == 0) { DocBuilder.AddContentLine(ref _flowDocument, "", new DocContentItem("This system's " + NodeName + " is empty and barren. Maybe there was something here once, but there's nothing left now. ")); } }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 5); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } DocBuilder.AddContentLine(ref _flowDocument, "Type", new DocContentItem("Large Asteroid", 16)); if (_inhabitants != Species.None) { DocBuilder.AddContentLine(ref _flowDocument, "Inhabitants", new DocContentItem(GetSpeciesText(_inhabitants))); DocBuilder.AddContentLine(ref _flowDocument, "Inhabitant Development", _inhabitantDevelopment); } }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 3); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } if (NumSolarFlaresInThisZone > 1) { DocBuilder.AddContentLine(ref _flowDocument, "", new DocContentItem("There are Solar Flares in this zone that are unusually strong. There are a total of " + NumSolarFlaresInThisZone + " instances of Solar Flares present, giving a +" + (NumSolarFlaresInThisZone - 1) + " bonus to the 1d10 roll for determining if there is a Solar Flare that day. ", 16, "Solar Flares")); } else { DocBuilder.AddContentLine(ref _flowDocument, "", new DocContentItem("There are Solar Flares in this zone of regular strength. There are no additional instances of Solar Flares present to add any further penalties. ", 16, "Solar Flares")); } }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 3); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } if (NumRadiationBurstsInThisZone > 1) { DocBuilder.AddContentLine(ref _flowDocument, "", new DocContentItem("There are Radiation Bursts that are unusually strong in this zone. There are a total of " + NumRadiationBurstsInThisZone + " instances of Radiation Bursts present, giving a -" + (NumRadiationBurstsInThisZone - 1) * 5 + " penalty to Detection after halving. ", 16, "Radiation Bursts")); } else { DocBuilder.AddContentLine(ref _flowDocument, "", new DocContentItem("There are Radiation Burst of regular strength in this zone. There are no additional instances of Radiation Bursts present to add any further penalties. ", 16, "Radiation Bursts")); } }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 2); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } if (_pirateDenContainsWayfarerStation) { DocBuilder.AddContentLine(ref _flowDocument, "Pirate Den", new DocContentItem("The pirates in this system are based around a space station (such as a Wayfarer Station).", 210, "Wayfarer Station", RuleBook.CoreRuleBook)); } if (Children.Count > 0) { DocBuilder.AddContentLine(ref _flowDocument, "Number of Pirate Ships Present", new DocContentItem(Children.Count.ToString(CultureInfo.InvariantCulture))); } }
public override ICollection <OverloadDoc> GetOverloads(object value) { BuiltinFunction bf = value as BuiltinFunction; if (bf != null) { return(GetBuiltinFunctionOverloads(bf)); } BuiltinMethodDescriptor bmd = value as BuiltinMethodDescriptor; if (bmd != null) { return(GetBuiltinFunctionOverloads(bmd.Template)); } PythonFunction pf = value as PythonFunction; if (pf != null) { return(new[] { new OverloadDoc( pf.__name__, pf.__doc__ as string, GetParameterDocs(pf) ) }); } Method method = value as Method; if (method != null) { return(GetOverloads(method.__func__)); } Delegate dlg = value as Delegate; if (dlg != null) { return(new[] { DocBuilder.GetOverloadDoc(dlg.GetType().GetMethod("Invoke"), dlg.GetType().Name, 0, false) }); } return(new OverloadDoc[0]); }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 3); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } DocBuilder.AddContentLine(ref _flowDocument, "Treasure Type", GetTreasureType()); DocBuilder.AddContentLine(ref _flowDocument, "Item", _treasureName); DocBuilder.AddContentLine(ref _flowDocument, "Origin", GetOriginTypeDoc()); DocBuilder.AddContentLine(ref _flowDocument, "Craftsmanship", GetCraftsmanship()); if (_origin == TreasureOrigin.AncientMiracle) { if (_miraclesOfTheDarkAge.Count == 1) { DocBuilder.AddContentLine(ref _flowDocument, "Miracles of the Dark Age", _miraclesOfTheDarkAge[0]); } else if (_miraclesOfTheDarkAge.Count > 1) { DocBuilder.AddContentList(ref _flowDocument, "Miracles of the Dark Age", _miraclesOfTheDarkAge); } } else if (_origin == TreasureOrigin.AlienTechnology) { DocBuilder.AddContentLine(ref _flowDocument, "Xenos Construction", _xenosConstruction); } else if (_origin == TreasureOrigin.CursedArtefact) { DocBuilder.AddContentLine(ref _flowDocument, "Mark of the Curse", _markOfTheCurse); } if (!String.IsNullOrWhiteSpace(_quirk1)) { DocBuilder.AddContentLine(ref _flowDocument, "Quirk", new DocContentItem(_quirk1, 92, "Table 2-35: Quirks")); } if (!String.IsNullOrWhiteSpace(_quirk2)) { DocBuilder.AddContentLine(ref _flowDocument, "Quirk", new DocContentItem(_quirk2, 92, "Table 2-35: Quirks")); } }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 3); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } DocBuilder.AddContentLine(ref _flowDocument, "Fleet Composition", new DocContentItem(_fleetComposition, 17, "Table 1-5: Starship Graveyard Origins")); if (Properties.Settings.Default.BookBattlefleetKoronus) { List <DocContentItem> items = _hulks.Select(hulk => hulk.GenerateDocItem()).ToList(); DocBuilder.AddContentList(ref _flowDocument, "Hulks", items); } else { DocBuilder.AddContentLine(ref _flowDocument, "Number of Hulks", new DocContentItem(_hulks.Count.ToString(CultureInfo.InvariantCulture))); } if (HasAdditionalResources()) { //DocBuilder.AddContentList(ref _flowDocument, "Resources", GetAdditionalResourceList()); if (_resourceArcheotechCache > 0) { DocBuilder.AddContentLine(ref _flowDocument, "Archeotech Resources", new DocContentItem(ResourceArcheotechCacheText, 28)); } if (_resourceXenosRuins > 0) { DocBuilder.AddContentLine(ref _flowDocument, "Xenotech Resources", new DocContentItem(ResourceXenosRuinsText, 31)); } } else { DocBuilder.AddContentLine(ref _flowDocument, "Resources", new DocContentItem("None")); } if (_inhabitants != Species.None) { DocBuilder.AddContentLine(ref _flowDocument, "Inhabitants", new DocContentItem(GetSpeciesText(_inhabitants))); DocBuilder.AddContentLine(ref _flowDocument, "Inhabitant Development", _inhabitantDevelopment); } }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 3); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } if (HasMineralResources()) { DocBuilder.AddContentList(ref _flowDocument, "Base Mineral Resources", GetMineralResourceList()); } else { DocBuilder.AddContentLine(ref _flowDocument, "Base Mineral Resources", new DocContentItem("None")); } if (_inhabitants != Species.None) { DocBuilder.AddContentLine(ref _flowDocument, "Inhabitants", new DocContentItem(GetSpeciesText(_inhabitants))); DocBuilder.AddContentLine(ref _flowDocument, "Inhabitant Development", _inhabitantDevelopment); } }
public void ValiDoc_WithNoChildValidatorAndDeepDocument_ReturnsRulesForAll() { var validator = new MultipleRuleValidator(); var ruleGenerator = new DocBuilder(new RuleDescriptionBuilder(new ValidatorErrorMessageBuilder(new FluentValidationHelpers()))); var validationRules = ruleGenerator.Document(validator).ToList(); validationRules.Should().HaveCount(3); var expectedOutput = new List <RuleDescription> { new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotNullValidator", ValidationMessage = "'First Name' must not be empty." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotEmptyValidator", ValidationMessage = "'Last Name' should not be empty." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "MaximumLengthValidator", ValidationMessage = "'Last Name' must be between {MinLength} and {MaxLength} characters. You entered {TotalLength} characters." } }; validationRules.ShouldBeEquivalentTo(expectedOutput, options => options.WithStrictOrdering()); }
private void GetAndSaveTmpVars() { long tmpId = this.InfoTmp.Tmp_Id; List <string> parms = null; DocBuilder docBuilder = new DocBuilder(this.InfoTmp); using (DocX document = DocX.Load(docBuilder.ToStream())) { string regEx = "\\$\\{[^\\$\\{\\}]*\\}"; parms = document.FindUniqueByPattern(regEx, RegexOptions.IgnoreCase); //string filename = System.IO.Path.Combine("Report", "tmp.docx"); //Doc.DocBuilder1.SetPageMargin(document); //document.SaveAs(filename); } if (!manager.SaveTmpVars(tmpId, parms)) { MessageBox.Show("模板提取变量失败"); } }
private static OverloadDoc GetOverloadDoc(string name, MethodBase method) { return(DocBuilder.GetOverloadDoc(method, name, 0)); }
public Director(DocBuilder constructor) => this.constructor = constructor;
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); //_flowDocument.IsColumnWidthFlexible = false; // Create stat block Table table = new Table(); DocBuilder.AddHeader(ref _flowDocument, NodeName, 5); if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } _flowDocument.Blocks.Add(table); const int numColumns = 9; for (int i = 0; i < numColumns; i++) { TableColumn column = new TableColumn { Width = GridLength.Auto }; //column.Width = new GridLength(35); table.Columns.Add(column); } table.CellSpacing = 0; table.RowGroups.Add(new TableRowGroup()); table.RowGroups[0].Rows.Add(new TableRow()); TableRow currentRow = table.RowGroups[0].Rows[0]; currentRow.FontSize = 12; currentRow.FontWeight = FontWeights.Bold; currentRow.Cells.Add(new TableCell(new Paragraph(new Run(NodeName)))); currentRow.Cells[0].ColumnSpan = numColumns; currentRow.Cells[0].BorderBrush = Brushes.Black; currentRow.Cells[0].BorderThickness = new Thickness(1); currentRow.Cells[0].Padding = new Thickness(2); table.RowGroups[0].Rows.Add(new TableRow()); currentRow = table.RowGroups[0].Rows[1]; currentRow.FontSize = 12; currentRow.FontWeight = FontWeights.Bold; currentRow.Cells.Add(new TableCell(new Paragraph(new Run("WS")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("BS")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("S")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("T")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Ag")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Int")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Per")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("WP")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Fel")))); for (int i = 0; i < numColumns; i++) { currentRow.Cells[i].TextAlignment = TextAlignment.Center; currentRow.Cells[i].BorderBrush = Brushes.Black; currentRow.Cells[i].BorderThickness = new Thickness(1); currentRow.Cells[i].Padding = new Thickness(2); } table.RowGroups[0].Rows.Add(new TableRow()); currentRow = table.RowGroups[0].Rows[2]; currentRow.FontSize = 9; //currentRow.FontWeight = FontWeights.Bold; currentRow.Cells.Add(new TableCell(new Paragraph(new Run("")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_xenos.GetUnnaturalStrengthTextForTable())))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_xenos.GetUnnaturalToughnessTextForTable())))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("")))); for (int i = 0; i < numColumns; i++) { currentRow.Cells[i].TextAlignment = TextAlignment.Left; currentRow.Cells[i].BorderBrush = Brushes.Black; currentRow.Cells[i].BorderThickness = new Thickness(1, 1, 1, 0); currentRow.Cells[i].Padding = new Thickness(2, 0, 0, 2); } table.RowGroups[0].Rows.Add(new TableRow()); currentRow = table.RowGroups[0].Rows[3]; currentRow.FontSize = 14; //currentRow.FontWeight = FontWeights.Bold; currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_xenos.Stats.GetStatTextForTable(_xenos.Stats.WeaponSkill))))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_xenos.Stats.GetStatTextForTable(_xenos.Stats.BallisticSkill))))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_xenos.Stats.GetStatTextForTable(_xenos.Stats.Strength))))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_xenos.Stats.GetStatTextForTable(_xenos.Stats.Toughness))))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_xenos.Stats.GetStatTextForTable(_xenos.Stats.Agility))))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_xenos.Stats.GetStatTextForTable(_xenos.Stats.Intelligence))))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_xenos.Stats.GetStatTextForTable(_xenos.Stats.Perception))))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_xenos.Stats.GetStatTextForTable(_xenos.Stats.WillPower))))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(_xenos.Stats.GetStatTextForTable(_xenos.Stats.Fellowship))))); for (int i = 0; i < numColumns; i++) { currentRow.Cells[i].TextAlignment = TextAlignment.Center; currentRow.Cells[i].BorderBrush = Brushes.Black; currentRow.Cells[i].BorderThickness = new Thickness(1, 0, 1, 1); currentRow.Cells[i].Padding = new Thickness(2, 0, 2, 2); } table.RowGroups[0].Rows.Add(new TableRow()); currentRow = table.RowGroups[0].Rows[4]; Paragraph paragraph = new Paragraph { FontSize = 12 }; paragraph.Inlines.Add(new Bold(new Run("Movement: "))); paragraph.Inlines.Add(new Run(_xenos.GetMovementString())); currentRow.Cells.Add(new TableCell(paragraph)); currentRow.Cells[0].ColumnSpan = 6; currentRow.Cells[0].Padding = new Thickness(2, 10, 2, 3); paragraph = new Paragraph { FontSize = 12 }; paragraph.Inlines.Add(new Bold(new Run("Wounds: "))); paragraph.Inlines.Add(new Run(_xenos.Wounds.ToString(CultureInfo.InvariantCulture))); currentRow.Cells.Add(new TableCell(paragraph)); currentRow.Cells[1].ColumnSpan = 3; currentRow.Cells[1].TextAlignment = TextAlignment.Right; currentRow.Cells[1].Padding = new Thickness(2, 10, 2, 3); table.RowGroups[0].Rows.Add(new TableRow()); currentRow = table.RowGroups[0].Rows[5]; paragraph = new Paragraph { FontSize = 12 }; paragraph.Inlines.Add(new Bold(new Run("Armour: "))); paragraph.Inlines.Add(new Run(_xenos.GetArmourText(_xenos is XenosPrimitive))); currentRow.Cells.Add(new TableCell(paragraph)); currentRow.Cells[0].ColumnSpan = 6; currentRow.Cells[0].Padding = new Thickness(2, 3, 2, 0); paragraph = new Paragraph { FontSize = 12 }; paragraph.Inlines.Add(new Bold(new Run("Total TB: "))); paragraph.Inlines.Add(new Run(_xenos.GetTotalToughnessBonus().ToString(CultureInfo.InvariantCulture))); currentRow.Cells.Add(new TableCell(paragraph)); currentRow.Cells[1].ColumnSpan = 3; currentRow.Cells[1].TextAlignment = TextAlignment.Right; currentRow.Cells[1].Padding = new Thickness(2, 3, 2, 0); // END generate table var xenos = _xenos as XenosStarsOfInequity; if (xenos != null) { DocBuilder.AddContentLine(ref _flowDocument, "Bestial Archetype", xenos.BestialArchetypeText); DocBuilder.AddContentLine(ref _flowDocument, "Bestial Nature", xenos.BestialNature); } var bestiary = _xenos as XenosKoronusBestiary; if (bestiary != null) { DocBuilder.AddContentLine(ref _flowDocument, "Base Profile", bestiary.BaseProfileText); if (bestiary.FloraType != FloraType.NotFlora) { DocBuilder.AddContentLine(ref _flowDocument, "Flora Type", bestiary.FloraTypeText); } } var primitive = _xenos as XenosPrimitive; if (primitive != null) { DocBuilder.AddContentLine(ref _flowDocument, "Unusual Xenos Communication", primitive.UnusualCommunication); DocBuilder.AddContentLine(ref _flowDocument, "Social Structure", primitive.SocialStructure); } DocBuilder.AddContentLine(ref _flowDocument, "Skills", new DocContentItem(_xenos.GetSkillList())); DocBuilder.AddContentLine(ref _flowDocument, "Talents", new DocContentItem(_xenos.GetTalentList())); if (Properties.Settings.Default.ShowPageNumbers) { DocBuilder.AddContentList(ref _flowDocument, "Traits", _xenos.Traits.GetTraitListDocContentItems()); } else { DocBuilder.AddContentLine(ref _flowDocument, "Traits", new DocContentItem(_xenos.GetTraitList())); } DocBuilder.AddContentLine(ref _flowDocument, "Weapons", new DocContentItem(_xenos.GetWeaponList())); }
public override void GenerateFlowDocument() { _flowDocument = new FlowDocument(); if (_isMoon) { DocBuilder.AddHeader(ref _flowDocument, NodeName, 5); } else { DocBuilder.AddHeader(ref _flowDocument, NodeName, 3); } if (!String.IsNullOrEmpty(Description)) { DocBuilder.AddContentLine(ref _flowDocument, "Description", new DocContentItem(Description)); } if (_isMoon) { string typeName = "Moon"; if (_maidenWorld) { typeName += " (Eldar Maiden World)"; } DocBuilder.AddContentLine(ref _flowDocument, "Type", new DocContentItem(typeName, 16)); } else { string typeName = "Planet"; if (_maidenWorld) { typeName += " (Eldar Maiden World)"; } DocBuilder.AddContentLine(ref _flowDocument, "Type", new DocContentItem(typeName, 16)); } DocBuilder.AddContentLine(ref _flowDocument, "Body", new DocContentItem(_body, 19, "Table 1-6: Body")); DocBuilder.AddContentLine(ref _flowDocument, "Gravity", new DocContentItem(_gravity, 20, "Table 1-7: Gravity")); DocBuilder.AddContentLine(ref _flowDocument, "Atmospheric Presence", new DocContentItem(_atmosphericPresence, 21, "Table 1-9: Atmospheric Presence")); DocBuilder.AddContentLine(ref _flowDocument, "Atmospheric Composition", new DocContentItem(_atmosphericComposition, 21, "Table 1-10: Atmospheric Composition")); DocBuilder.AddContentLine(ref _flowDocument, "Climate", new DocContentItem(_climate, 22, "Table 1-11: Climate")); DocBuilder.AddContentLine(ref _flowDocument, "Habitability", new DocContentItem(GetHabitabilityString(), 23, "Table 1-12: Habitability")); DocBuilder.AddContentLine(ref _flowDocument, "Major Continents or Archipelagos", new DocContentItem(GetNumberOfContinentsText(), 23, "Landmasses")); DocBuilder.AddContentLine(ref _flowDocument, "Smaller Islands", new DocContentItem(GetNumberOfIslandsText(), 23, "Landmasses")); List <DocContentItem> territoryList = _environment.GetListOfTerritories(); if (territoryList.Count == 0) { DocBuilder.AddContentLine(ref _flowDocument, "Territories", new DocContentItem("None")); } else { DocBuilder.AddContentList(ref _flowDocument, "Territories", territoryList); } foreach (Territory territory in _environment.Territories) { List <DocContentItem> landmarkList = territory.GetLandmarkList(); if (landmarkList.Count == 1) { DocBuilder.AddContentLine(ref _flowDocument, "Landmarks in " + _environment.GetBaseTerrainName(territory.BaseTerrain), landmarkList[0]); } else if (landmarkList.Count > 1) { DocBuilder.AddContentList(ref _flowDocument, "Landmarks in " + _environment.GetBaseTerrainName(territory.BaseTerrain), landmarkList); } else { DocBuilder.AddContentLine(ref _flowDocument, "Landmarks in " + _environment.GetBaseTerrainName(territory.BaseTerrain), new DocContentItem("None")); } } if (HasMineralResources()) { List <DocContentItem> mineralResourceList = GetMineralResourceList(); if (mineralResourceList.Count == 1) { DocBuilder.AddContentLine(ref _flowDocument, "Base Mineral Resources", mineralResourceList[0]); } else { DocBuilder.AddContentList(ref _flowDocument, "Base Mineral Resources", mineralResourceList); } } else { DocBuilder.AddContentLine(ref _flowDocument, "Base Mineral Resources", new DocContentItem("None")); } List <DocContentItem> organicCompounds = GetOrganicCompoundList(); if (organicCompounds.Count == 1) { DocBuilder.AddContentLine(ref _flowDocument, "Organic Compounds", organicCompounds[0]); } else if (organicCompounds.Count > 1) { DocBuilder.AddContentList(ref _flowDocument, "Organic Compounds", organicCompounds); } else { DocBuilder.AddContentLine(ref _flowDocument, "Organic Compounds", new DocContentItem("None")); } if (_resourceArcheotechCache > 0) { DocBuilder.AddContentLine(ref _flowDocument, "Archeotech Caches", new DocContentItem(ResourceArcheotechCacheText, 28)); } else { DocBuilder.AddContentLine(ref _flowDocument, "Archeotech Caches", new DocContentItem("None")); } if (_resourceXenosRuins > 0) { DocBuilder.AddContentLine(ref _flowDocument, "Xenos Ruins", GetXenosRuinsDocContentItem()); } else { DocBuilder.AddContentLine(ref _flowDocument, "Xenos Ruins", new DocContentItem("None")); } string speciesText = GetSpeciesText(_inhabitants); if (_isInhabitantHomeWorld) { speciesText += " (Home World)"; } DocBuilder.AddContentLine(ref _flowDocument, "Inhabitants", new DocContentItem(speciesText)); if (_inhabitants != Species.None) { DocBuilder.AddContentLine(ref _flowDocument, "Inhabitant Development", _inhabitantDevelopment); if (_primitiveXenosNode != null && _primitiveXenosNode.Children.Count > 0) { DocBuilder.AddContentLine(ref _flowDocument, "The Koronus Bestiary", new DocContentItem("More information about inhabitant species below")); } } if (_warpStorm) { DocBuilder.AddContentLine(ref _flowDocument, "Warp Storm", new DocContentItem("This planet is engulfed in a permanent Warp storm, rendering it inaccessible to all but the most dedicated (and insane) of travellers. ", 12, "Warp Turbulence")); } }
public void ValiDoc_WithMultipleChildValidatorsAndDeepDocument_ReturnsRulesForAllChildValidators() { var validator = new MultipleRuleMultipleChildValidator(); var ruleGenerator = new DocBuilder(new RuleDescriptionBuilder(new ValidatorErrorMessageBuilder(new FluentValidationHelpers()))); var validationRules = ruleGenerator.Document(validator).ToList(); validationRules.Should().HaveCount(11); var expectedOutput = new List <RuleDescription> { new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotEmptyValidator", ValidationMessage = "'First Name' should not be empty." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotEmptyValidator", ValidationMessage = "'Last Name' should not be empty." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "MaximumLengthValidator", ValidationMessage = "'Last Name' must be between {MinLength} and {MaxLength} characters. You entered {TotalLength} characters." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotEmptyValidator", ValidationMessage = "'House Number' should not be empty." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotEmptyValidator", ValidationMessage = "'Street Name' should not be empty." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotEmptyValidator", ValidationMessage = "'Post Code' should not be empty." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "AddressValidator", ValidationMessage = null }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotEqualValidator", ValidationMessage = "'Employment Status' should not be equal to '{ComparisonValue}'." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "EnumValidator", ValidationMessage = "'Employment Status' has a range of values which does not include 'NotSet'." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "NotEmptyValidator", ValidationMessage = "'Job Title' should not be empty." }, new RuleDescription { FailureSeverity = "Error", OnFailure = "Continue", ValidatorName = "OccupationDetailsValidator", ValidationMessage = null } }; validationRules.ShouldBeEquivalentTo(expectedOutput, options => options.WithStrictOrdering()); }