private void UpdateQuantities() { // Initialize all quantities back to zero foreach (Object Placeholder in Placeholders.SelectMany(x => x.Value.Values)) { Placeholder.Stack = 0; } // Set quantities of the placeholder items to match the corresponding amount of the item currently stored in the bag foreach (Object Item in Bag.Contents) { if (Placeholders.TryGetValue(Item.ParentSheetIndex, out Dictionary <ObjectQuality, Object> Group)) { ObjectQuality Quality = (ObjectQuality)Item.Quality; if (Group.TryGetValue(Quality, out Object Placeholder)) { ItemBag.ForceSetQuantity(Placeholder, Item.Stack); if (Placeholder.Price != Item.Price) { #if DEBUG string WarningMsg = string.Format("Warning - GroupedLayout placeholder item '{0}' does not have a matching price to the corresponding item in the bag." + " Placeholder.Price={1}, BagItem.Price={2}", Placeholder.DisplayName, Placeholder.Price, Item.Price); ItemBagsMod.ModInstance.Monitor.Log(WarningMsg, LogLevel.Warn); #endif Placeholder.Price = Item.Price; } } } } }
private void GenerateStructure(IContainer container, int level) { if (level <= 0) { container.Background(Placeholders.BackgroundColor()).Height(10); return; } level--; if (level % 3 == 0) { container .Border(level / 4f) .BorderColor(Colors.Black) .Row(row => { row.RelativeItem().Element(x => GenerateStructure(x, level)); row.RelativeItem().Element(x => GenerateStructure(x, level)); }); } else { container .Border(level / 4f) .BorderColor(Colors.Black) .Column(column => { column.Item().Element(x => GenerateStructure(x, level)); column.Item().Element(x => GenerateStructure(x, level)); }); } }
public void DefaultTextStyle() { RenderingTest .Create() .ProducePdf() .ShowResults() .RenderDocument(container => { container.Page(page => { // all text in this set of pages has size 20 page.DefaultTextStyle(TextStyle.Default.Size(20)); page.Margin(20); page.Size(PageSizes.A4); page.PageColor(Colors.White); page.Content().Column(column => { column.Item().Text(Placeholders.Sentence()); column.Item().Text(text => { // text in this block is additionally semibold text.DefaultTextStyle(TextStyle.Default.SemiBold()); text.Line(Placeholders.Sentence()); // this text has size 20 but also semibold and red text.Span(Placeholders.Sentence()).FontColor(Colors.Red.Medium); }); }); }); }); }
public void ScaleToFit() { RenderingTest .Create() .PageSize(PageSizes.A4) .ProduceImages() .ShowResults() .Render(container => { container.Padding(25).Column(column => { var text = Placeholders.Paragraph(); foreach (var i in Enumerable.Range(2, 5)) { column .Item() .MinimalBox() .Border(1) .Padding(5) .Width(i * 40) .Height(i * 20) .ScaleToFit() .Text(text); } }); }); }
public void TextElements() { RenderingTest .Create() .PageSize(PageSizes.A4) .ProducePdf() .ShowResults() .Render(container => { container .Padding(20) .Padding(10) .MinimalBox() .Border(1) .Padding(5) .Padding(10) .Text(text => { text.DefaultTextStyle(TextStyle.Default); text.AlignLeft(); text.ParagraphSpacing(10); text.Line(Placeholders.LoremIpsum()); text.Span($"This is target text that should show up. {DateTime.UtcNow:T} > This is a short sentence that will be wrapped into second line hopefully, right? <").Underline(); }); }); }
public void ParagraphSpacing() { RenderingTest .Create() .PageSize(500, 300) .ProduceImages() .ShowResults() .Render(container => { container .Padding(5) .MinimalBox() .Border(1) .Padding(10) .Text(text => { text.ParagraphSpacing(10); foreach (var i in Enumerable.Range(1, 3)) { text.Span($"Paragraph {i}: ").SemiBold(); text.Line(Placeholders.Paragraph()); } }); }); }
public void BreakingLongWord() { RenderingTest .Create() .ProduceImages() .ShowResults() .RenderDocument(container => { container.Page(page => { page.Margin(50); page.PageColor(Colors.White); page.Size(PageSizes.A4); page.Content().Column(column => { column.Item().Text(null); column.Item().Text(text => { text.DefaultTextStyle(x => x.BackgroundColor(Colors.Red.Lighten3).FontSize(24)); text.Span(" " + Placeholders.LoremIpsum()); text.Span(" 0123456789012345678901234567890123456789012345678901234567890123456789 ").WrapAnywhere(); }); }); }); }); }
public void TestRendering() { ModelProvider <CustomModel> modelProvider = (r, h) => new CustomModel(r, h); var providers = new List <IHandlerBuilder>() { ModScriban.Page(Data.FromString("Hello {{ world }}!"), modelProvider), ModRazor.Page(Data.FromString("Hello @Model.World!"), modelProvider), Placeholders.Page(Data.FromString("Hello [World]!"), modelProvider) }; foreach (var provider in providers) { var layout = Layout.Create().Add("page", provider); using var runner = TestRunner.Run(layout); using var response = runner.GetResponse("/page"); var content = response.GetContent(); Assert.NotEqual("Hello World!", content); Assert.Contains("Hello World!", content); } }
public void SyntaxErrorMissingBrace() { var placeholders = new Placeholders(); placeholders["dir"] = "bla"; Assert.Equal(@"${dir\file.txt", placeholders.ResolvePlaceholders(@"${dir\file.txt")); }
public void Example() { RenderingTest .Create() .PageSize(300, 250) .ProduceImages() .ShowResults() .Render(container => { container .Padding(25) .DefaultTextStyle(TextStyle.Default.Size(14)) .Decoration(decoration => { decoration .Before() .Text(text => { text.DefaultTextStyle(TextStyle.Default.SemiBold().Color(Colors.Blue.Medium)); text.Span("Page "); text.CurrentPageNumber(); }); decoration .Content() .Column(column => { column.Spacing(25); column.Item().StopPaging().Text(Placeholders.LoremIpsum()); column.Item().ExtendHorizontal().Height(75).Background(Colors.Grey.Lighten2); }); }); }); }
public void PlaceholderFillsInput() { var placeholders = new Placeholders(); placeholders["dir"] = "bla"; Assert.Equal("bla", placeholders.ResolvePlaceholders("${dir}")); }
public void MultiplePlaceholdersWith1stUnknown() { var placeholders = new Placeholders(); placeholders["file"] = "text.txt"; Assert.Equal(@"${dir}\text.txt", placeholders.ResolvePlaceholders(@"${dir}\${file}")); }
public void PlaceholderAtBeginningWithOtherParts() { var placeholders = new Placeholders(); placeholders["dir"] = "bla"; Assert.Equal(@"bla\file.txt", placeholders.ResolvePlaceholders(@"${dir}\file.txt")); }
public void PlaceholderInTheMiddleWithOtherParts() { var placeholders = new Placeholders(); placeholders["file"] = "text"; Assert.Equal(@"bla\text.txt", placeholders.ResolvePlaceholders(@"bla\${file}.txt")); }
public void Column() { RenderingTest .Create() .PageSize(PageSizes.A4) .ShowResults() .ProducePdf() .Render(container => { container.Column(column => { foreach (var i in Enumerable.Range(0, 10)) { column.Item().Element(Block); } static void Block(IContainer container) { container .Width(72) .Height(3.5f, Unit.Inch) .Height(1.5f, Unit.Inch) .Background(Placeholders.BackgroundColor()); } });
public void Save(System.IO.TextWriter stream) { RemoveDuplicateElements(); var ms = new MemoryStream(); doc.Save(ms); ms.Flush(); ms.Position = 0; var s = new StreamReader(ms).ReadToEnd(); if (ApplicationName != null) { s = s.Replace("${applicationId}", ApplicationName); } if (Placeholders != null) { foreach (var entry in Placeholders.Select(e => e.Split(new char [] { '=' }, 2, StringSplitOptions.None))) { if (entry.Length == 2) { s = s.Replace("${" + entry [0] + "}", entry [1]); } else { log.LogWarning("Invalid application placeholders (AndroidApplicationPlaceholders) value. Use 'key1=value1;key2=value2, ...' format. The specified value was: " + Placeholders); } } } stream.Write(s); }
public void SkipOnce() { RenderingTest .Create() .ProduceImages() .ShowResults() .RenderDocument(container => { container.Page(page => { page.Margin(20); page.Size(PageSizes.A7.Landscape()); page.PageColor(Colors.White); page.Header().Column(column => { column.Item().ShowOnce().Text("This header is visible on the first page."); column.Item().SkipOnce().Text("This header is visible on the second page and all following."); }); page.Content() .PaddingVertical(10) .Text(Placeholders.Paragraphs()) .FontColor(Colors.Grey.Medium); page.Footer().Text(text => { text.Span("Page "); text.CurrentPageNumber(); text.Span(" out of "); text.TotalPages(); }); }); }); }
public HttpResponseHeaderReplacerTests() { _repo = new Mock <IRequestScopedDataRepository>(); _finder = new Mock <IBaseUrlFinder>(); _placeholders = new Placeholders(_finder.Object, _repo.Object); _replacer = new HttpResponseHeaderReplacer(_placeholders); }
public void NoPlaceholder() { var placeholders = new Placeholders(); placeholders["dir"] = "bla"; Assert.Equal(@"bla\bla", placeholders.ResolvePlaceholders(@"bla\bla")); }
public void PagingSupport() { RenderingTest .Create() .ProducePdf() .PageSize(420, 220) .ShowResults() .Render(container => { container .Padding(10) .MinimalBox() .Border(1) .Table(table => { table.ColumnsDefinition(columns => { columns.RelativeColumn(); columns.RelativeColumn(); columns.RelativeColumn(); columns.RelativeColumn(); }); // by using custom 'Element' method, we can reuse visual configuration table.Cell().Element(Block).Text(Placeholders.Label()); table.Cell().Element(Block).Text(Placeholders.Label()); table.Cell().Element(Block).Text(Placeholders.Paragraph()); table.Cell().Element(Block).Text(Placeholders.Label()); }); }); }
public void TestSessionIdWithNullConnection() { string text = @"hello {$session_id} there"; string output = Placeholders.Substitute(text, new Host()); Assert.AreEqual("hello null there", output, "null connection session_id didn't work"); }
public void TestInvalidSessionIdPlaceholder() { IXenObject host = GetAnyHost(); string output = Placeholders.Substitute(@"hello {$sesion_id} there", host); Assert.AreEqual("hello {$sesion_id} there", output, "null connection session_id didn't work"); }
private void UpdatePlaceholders() { Placeholders.Clear(); List <GameObject> placeholdersTemp = new List <GameObject>(); placeholdersTemp.Clear(); foreach (var go in GetComponentsInChildren <Transform>()) { if (go.gameObject.name == "Placeholders") { foreach (var placeholder in go.GetComponentsInChildren <Transform>()) { if (placeholder.name != "Placeholders") { placeholdersTemp.Add(placeholder.gameObject); } } break; } } foreach (var placeholder in placeholdersTemp) { Placeholders.Add(placeholder.gameObject); } }
public void SamePlaceHolderMultipleTimes() { var placeholders = new Placeholders(); placeholders["dir"] = "bla"; Assert.Equal(@"bla\bla", placeholders.ResolvePlaceholders(@"${dir}\${dir}")); }
public void Textcolumn() { RenderingTest .Create() .PageSize(PageSizes.A4) .ProducePdf() .ShowResults() .Render(container => { container .Padding(20) .Padding(10) .MinimalBox() .Border(1) .Padding(5) .Padding(10) .Text(text => { text.DefaultTextStyle(TextStyle.Default); text.AlignLeft(); text.ParagraphSpacing(10); foreach (var i in Enumerable.Range(1, 100)) { text.Line($"{i}: {Placeholders.Paragraph()}"); } }); }); }
public override string ToArgs() { List <string> options = new List <string> { Url.Formatted(), Driver.Formatted(), User.Formatted(), Password.Formatted(), ConnectRetries.Formatted(), InitSql.Formatted(), Schemas.Formatted(), Table.Formatted(), Locations.Formatted(), JarDirs.Formatted(), SqlMigrationPrefix.Formatted(), UndoSqlMigrationPrefix.Formatted(), RepeatableSqlMigrationPrefix.Formatted(), SqlMigrationSeparator.Formatted(), SqlMigrationSuffixes.Formatted(), Stream.Formatted(), Batch.Formatted(), Mixed.Formatted(), Group.Formatted(), Encoding.Formatted(), PlaceholderReplacement.Formatted(), Placeholders.Formatted(), PlaceholderPrefix.Formatted(), PlaceholderSuffix.Formatted(), Resolvers.Formatted(), SkipDefaultResolvers.Formatted(), Callbacks.Formatted(), SkipDefaultCallbacks.Formatted(), Target.Formatted(), OutOfOrder.Formatted(), ValidateOnMigrate.Formatted(), CleanOnValidationError.Formatted(), IgnoreMissingMigrations.Formatted(), IgnoreIgnoredMigrations.Formatted(), IgnoreFutureMigrations.Formatted(), CleanDisabled.Formatted(), BaselineOnMigrate.Formatted(), BaselineVersion.Formatted(), BaselineDescription.Formatted(), InstalledBy.Formatted(), ErrorOverrides.Formatted(), DryRunOutput.Formatted(), OracleSqlplus.Formatted(), LicenseKey.Formatted(), DefaultSchema.Formatted(), TableSpace.Formatted(), Color.Formatted(), ValidateMigrationNaming.Formatted(), OutputQueryResults.Formatted(), OracleSqlplusWarn.Formatted(), WorkingDirectory.Formatted() }; return(ToArgs(options)); }
public void SyntaxErrorMissingBraceWithOtherVariableStarting() { var placeholders = new Placeholders(); placeholders["dir"] = "bla"; placeholders["file"] = "text"; Assert.Equal(@"${dir\${file}.txt", placeholders.ResolvePlaceholders(@"${dir\${file}.txt")); }
public void Test_UrlReplacement_VM() { MW(delegate() { SelectInTree(GetAnyVM()); Placeholders.SubstituteURL(GetAllProperties(), Program.MainWindow.SelectedXenObject); }); }
public void MultiplePlaceholders() { var placeholders = new Placeholders(); placeholders["dir"] = "bla"; placeholders["file"] = "text.txt"; Assert.Equal(@"bla\text.txt", placeholders.ResolvePlaceholders(@"${dir}\${file}")); }
public bool CanExecuteSupportedSteps(IEnumerable <BackupStep> backupSteps, Placeholders placeholders) { return(!backupSteps .Where(step => step.StepType == Type) .SelectMany(GetRelevantPathsOfStep) .SelectMany(placeholders.ExtractPlaceholders) .Any(result => result.Placeholder.StartsWith("drive:") && result.Resolved == null)); }
public static bool HasBlock(Placeholders pch, XmlTag middleBlock) { bool status = false; status = middleBlock.LSTChildNodes.Exists( delegate(XmlTag tag) { return (Utils.CompareStrings(Utils.GetAttributeValueByName(tag, XmlAttributeTypes.NAME), pch)); } ); return status; }
/// <summary> /// Calculates the column width for the middle block /// Takes the ColumnWidth from the Parent Node which applies to right and left /// However the inline "width" attributes overrides the Parent's colwidth attribute /// </summary> /// <param name="section"></param> /// <param name="_type"></param> /// <returns></returns> public static string CalculateColumnWidth(XmlTag section, Placeholders _type) { string width = "20"; foreach (XmlTag tag in section.LSTChildNodes) { if (Utils.CompareStrings(_type, Utils.GetAttributeValueByName(tag, XmlAttributeTypes.NAME))) { int widthIndex = -1; widthIndex = tag.LSTAttributes.FindIndex( delegate(LayoutAttribute tagAttr) { return (Utils.CompareStrings(tagAttr.Name, XmlAttributeTypes.WIDTH)); } ); if (widthIndex > -1) { width = tag.LSTAttributes[widthIndex].Value; } else { foreach (LayoutAttribute attr in section.LSTAttributes) { if (Utils.CompareStrings(attr.Name, XmlAttributeTypes.WIDTH)) { width = attr.Value; } else if (Utils.CompareStrings(attr.Name, XmlAttributeTypes.COLWIDTH)) { width = attr.Value; } } } } } return width; }
/// <summary> /// Obtain inner HTML tag. /// </summary> /// <param name="pch">Placeholders.<see cref="T:SageFrame.Templating.Placeholders"/></param> /// <param name="middleBlock"></param> /// <returns></returns> public static string GetTagInnerHtml(Placeholders pch, XmlTag middleBlock) { XmlTag currentTag = new XmlTag(); currentTag = middleBlock.LSTChildNodes.Find( delegate(XmlTag tag) { return (Utils.CompareStrings(Utils.GetAttributeValueByName(tag, XmlAttributeTypes.NAME), pch)); } ); return currentTag.InnerHtml; }
/// <summary> /// Obtain side markups. /// </summary> /// <param name="Mode">Mode</param> /// <param name="lstWrapper">List of CustomWrapper class.</param> /// <param name="middleblock">Object of XmlTag class.</param> /// <param name="placeholder">Placeholders <see cref="T:SageFrame.Templating.Placeholders"/> </param> /// <returns>String format of side markup.</returns> public static string GetLeftRightTopBottom(int Mode, List<CustomWrapper> lstWrapper, XmlTag middleblock, Placeholders placeholder) { StringBuilder sb = new StringBuilder(); sb.Append(BlockParser.ProcessMiddlePlaceholders(placeholder, middleblock, lstWrapper, Mode)); return sb.ToString(); }
/// <summary> /// Obtain left right column markup. /// </summary> /// <param name="width">Width</param> /// <param name="Mode">Mode</param> /// <param name="placeholder">Placeholders <see cref="T:SageFrame.Templating.Placeholders"/> </param> /// <param name="lstWrapper">List of CustomWrapper class.</param> /// <param name="middleblock">Object of XmlTag class.</param> /// <returns>String format of left right column markup. </returns> public static string GetLeftRightCol(string width, int Mode, Placeholders placeholder, List<CustomWrapper> lstWrapper, XmlTag middleblock) { StringBuilder sb = new StringBuilder(); sb.Append("<div class='sfColswrap sfSingle sfCurve clearfix'>"); sb.Append(BlockParser.ProcessLeftRightPlaceholders(placeholder, middleblock, lstWrapper, Mode, width)); sb.Append("</div>"); return sb.ToString(); }
public static string ProcessLeftRightPlaceholders(Placeholders placeholder, XmlTag middleblock, List<CustomWrapper> lstWrapper, int _Mode,string Width) { Mode = _Mode; StringBuilder sb = new StringBuilder(); bool isAvailable = false; foreach (XmlTag pch in middleblock.LSTChildNodes) { if (Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME).ToLower() == placeholder.ToString().ToLower()) { foreach (CustomWrapper start in lstWrapper) { if (start.Type == "placeholder" && Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME).ToLower().Equals(start.Start)) { string style = ""; for (int i = 1; i <= start.Depth; i++) { if (i == 1) { style = start.Depth > 1 ? string.Format("sfBlockwrap {0}", start.Class) : string.Format("sfBlockwrap {0} clearfix", start.Class); sb.Append("<div class='" + style + "'>"); } else { style = start.Depth == i ? string.Format("sfBlockwrap {0} sf{1} clearfix", start.Class, i) : string.Format("sfBlockwrap {0} sf{1}", start.Class, i); sb.Append("<div class='" + style + "'>"); } } } } string[] positions = pch.InnerHtml.Split(','); int mode = Utils.GetAttributeValueByName(pch, XmlAttributeTypes.MODE) == "" ? 0 : 1; string wrapperclass = string.Format("sf{0} clearfix", Utils.UppercaseFirst(Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME))); wrapperclass = string.Format("{0} {1}", wrapperclass, Utils.GetAttributeValueByName(pch, XmlAttributeTypes.CLASS)); string colwidth = string.Format("class='{0}' style='width:{1}'",wrapperclass,Width); sb.Append("<div "+colwidth+">"); switch (mode) { case 0: sb.Append(ParseNormalLeftRightBlocks(pch, lstWrapper)); break; case 1: sb.Append(ParseFixedBlocks(pch, lstWrapper)); break; } sb.Append("</div>"); foreach (CustomWrapper start in lstWrapper) { string pchName = Utils.GetAttributeValueByName(pch, XmlAttributeTypes.NAME).ToLower(); if (start.Type == "placeholder" && pchName.Equals(start.End)) { for (int i = 1; i <= start.Depth; i++) { sb.Append("</div>"); } } } isAvailable = true; } } if (!isAvailable) { sb.Append(Mode == 2 ? "<div class='" + placeholder.ToString().ToLower() + "'><div class='sfWrapper'>" : "<div class='" + placeholder.ToString().ToLower() + "'><div class='sfWrapper sfCurve'>"); sb.Append(HtmlBuilder.AddPlaceholder(placeholder.ToString().ToLower(), Mode)); sb.Append("</div></div>"); } return sb.ToString(); }