Browse Source

Improved developer experience via injecting Element() and Component() content in separate containers

Marcin Ziąbek 4 years ago
parent
commit
b894262f7e

+ 1 - 1
QuestPDF.ReportSample/Layouts/SectionTemplate.cs

@@ -72,7 +72,7 @@ namespace QuestPDF.ReportSample.Layouts
                 return;
                 return;
             }
             }
 
 
-            container.Debug("Photo gallery").Grid(grid =>
+            container.Debug("Photos").Grid(grid =>
             {
             {
                 grid.Spacing(5);
                 grid.Spacing(5);
                 grid.Columns(3);
                 grid.Columns(3);

+ 5 - 5
QuestPDF.UnitTests/GridTests.cs

@@ -40,7 +40,7 @@ namespace QuestPDF.UnitTests
             // assert
             // assert
             var expected = new Container();
             var expected = new Container();
             
             
-            expected.Stack(stack =>
+            expected.Container().Stack(stack =>
             {
             {
                 stack.Item().Row(row =>
                 stack.Item().Row(row =>
                 {
                 {
@@ -94,7 +94,7 @@ namespace QuestPDF.UnitTests
             // assert
             // assert
             var expected = new Container();
             var expected = new Container();
             
             
-            expected.Stack(stack =>
+            expected.Container().Stack(stack =>
             {
             {
                 stack.Item().Row(row =>
                 stack.Item().Row(row =>
                 {
                 {
@@ -151,7 +151,7 @@ namespace QuestPDF.UnitTests
             // assert
             // assert
             var expected = new Container();
             var expected = new Container();
             
             
-            expected.Stack(stack =>
+            expected.Container().Stack(stack =>
             {
             {
                 stack.Item().Row(row =>
                 stack.Item().Row(row =>
                 {
                 {
@@ -211,7 +211,7 @@ namespace QuestPDF.UnitTests
             // assert
             // assert
             var expected = new Container();
             var expected = new Container();
             
             
-            expected.Stack(stack =>
+            expected.Container().Stack(stack =>
             {
             {
                 stack.Spacing(20);
                 stack.Spacing(20);
                 
                 
@@ -244,7 +244,7 @@ namespace QuestPDF.UnitTests
                 });
                 });
             });
             });
             
             
-            structure.Should().BeEquivalentTo(expected, o => o.WithTracing().WithAutoConversion().WithStrictOrdering().IncludingAllRuntimeProperties());
+            structure.Should().BeEquivalentTo(expected, o => o.WithTracing().WithAutoConversion().WithStrictOrdering().IncludingAllRuntimeProperties().AllowingInfiniteRecursion());
         }
         }
         
         
         #endregion
         #endregion

+ 1 - 1
QuestPDF/Fluent/ComponentExtentions.cs

@@ -56,7 +56,7 @@ namespace QuestPDF.Fluent
             var descriptor = new ComponentDescriptor<T>(component);
             var descriptor = new ComponentDescriptor<T>(component);
             handler?.Invoke(descriptor);
             handler?.Invoke(descriptor);
             
             
-            component.Compose(element);
+            component.Compose(element.Container());
         }
         }
         
         
         static void Component<T>(this IContainer element, Action<ComponentDescriptor<T>>? handler = null) where T : IComponent, new()
         static void Component<T>(this IContainer element, Action<ComponentDescriptor<T>>? handler = null) where T : IComponent, new()

+ 3 - 3
QuestPDF/Fluent/ElementExtensions.cs

@@ -14,7 +14,7 @@ namespace QuestPDF.Fluent
             return container;
             return container;
         }
         }
 
 
-        public static T Element<T>(this IContainer element, T child) where T : IElement
+        internal static T Element<T>(this IContainer element, T child) where T : IElement
         {
         {
             if (element?.Child != null && element.Child is Empty == false)
             if (element?.Child != null && element.Child is Empty == false)
             {
             {
@@ -33,12 +33,12 @@ namespace QuestPDF.Fluent
         
         
         public static void Element<TParent>(this TParent parent, Action<IContainer> handler) where TParent : IContainer
         public static void Element<TParent>(this TParent parent, Action<IContainer> handler) where TParent : IContainer
         {
         {
-            handler(parent);
+            handler(parent.Container());
         }
         }
         
         
         public static IContainer Element<TParent>(this TParent parent, Func<IContainer, IContainer> handler) where TParent : IContainer
         public static IContainer Element<TParent>(this TParent parent, Func<IContainer, IContainer> handler) where TParent : IContainer
         {
         {
-            return handler(parent);
+            return handler(parent.Container()).Container();
         }
         }
 
 
         public static void PageNumber(this IContainer element, string textFormat = "{number}", TextStyle? style = null)
         public static void PageNumber(this IContainer element, string textFormat = "{number}", TextStyle? style = null)

+ 1 - 1
QuestPDF/QuestPDF.csproj

@@ -4,7 +4,7 @@
         <Authors>MarcinZiabek</Authors>
         <Authors>MarcinZiabek</Authors>
         <Company>CodeFlint</Company>
         <Company>CodeFlint</Company>
         <PackageId>QuestPDF</PackageId>
         <PackageId>QuestPDF</PackageId>
-        <Version>2021.5</Version>
+        <Version>2021.5.1</Version>
         <PackageDescription>QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API.</PackageDescription>
         <PackageDescription>QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API.</PackageDescription>
         <PackageReleaseNotes>New elements: Box, Grid, Canvas, EnsureSpance and Layers. Redesigned the Debug element. Added material design colors. Added list of basic fonts. Added spacing property to the Row element. Fluent API improvements and increased stability.</PackageReleaseNotes>
         <PackageReleaseNotes>New elements: Box, Grid, Canvas, EnsureSpance and Layers. Redesigned the Debug element. Added material design colors. Added list of basic fonts. Added spacing property to the Row element. Fluent API improvements and increased stability.</PackageReleaseNotes>
         <LangVersion>8</LangVersion>
         <LangVersion>8</LangVersion>