Browse Source

Fixed: conditional checking for Empty slots is not working correctly for Page and Decoration elements

Marcin Ziąbek 1 year ago
parent
commit
99ed12cd4f

+ 1 - 1
Source/QuestPDF.Examples/Engine/RenderingTest.cs

@@ -25,7 +25,7 @@ namespace QuestPDF.Examples.Engine
         private bool ApplyDebugging { get; set; }
         private RenderingTestResult ResultType { get; set; } = RenderingTestResult.Images;
 
-        private static readonly bool ShowingResultsEnabled = (Environment.GetEnvironmentVariable("TEST_SHOW_RESULTS") ?? "true") == "true";
+        private static readonly bool ShowingResultsEnabled = false; //(Environment.GetEnvironmentVariable("TEST_SHOW_RESULTS") ?? "true") == "true";
         
         private RenderingTest()
         {

+ 3 - 3
Source/QuestPDF/Fluent/DecorationExtensions.cs

@@ -17,7 +17,7 @@ namespace QuestPDF.Fluent
         /// </remarks>
         public IContainer Before()
         {
-            if (Decoration.Before != Empty.Instance)
+            if (Decoration.Before is not Empty)
                 throw new DocumentComposeException("The 'Decoration.Before' layer has already been defined. Please call this method only once.");
 
             var container = new RepeatContent();
@@ -44,7 +44,7 @@ namespace QuestPDF.Fluent
         /// </remarks>
         public IContainer Content()
         {
-            if (Decoration.Content != Empty.Instance)
+            if (Decoration.Content is not Empty)
                 throw new DocumentComposeException("The 'Decoration.Content' layer has already been defined. Please call this method only once.");
             
             var container = new Container();
@@ -71,7 +71,7 @@ namespace QuestPDF.Fluent
         /// </remarks>
         public IContainer After()
         {
-            if (Decoration.After != Empty.Instance)
+            if (Decoration.After is not Empty)
                 throw new DocumentComposeException("The 'Decoration.After' layer has already been defined. Please call this method only once.");
             
             var container = new RepeatContent();

+ 5 - 5
Source/QuestPDF/Fluent/PageExtensions.cs

@@ -210,7 +210,7 @@ namespace QuestPDF.Fluent
         /// </remarks>
         public IContainer Background()
         {
-            if (Page.Background != Empty.Instance)
+            if (Page.Background is not Empty)
                 throw new DocumentComposeException("The 'Page.Background' layer has already been defined. Please call this method only once.");
             
             var container = new Container();
@@ -226,7 +226,7 @@ namespace QuestPDF.Fluent
         /// </remarks>
         public IContainer Foreground()
         {
-            if (Page.Foreground != Empty.Instance)
+            if (Page.Foreground is not Empty)
                 throw new DocumentComposeException("The 'Page.Foreground' layer has already been defined. Please call this method only once.");
             
             var container = new Container();
@@ -242,7 +242,7 @@ namespace QuestPDF.Fluent
         /// </remarks>
         public IContainer Header()
         {
-            if (Page.Header != Empty.Instance)
+            if (Page.Header is not Empty)
                 throw new DocumentComposeException("The 'Page.Header' layer has already been defined. Please call this method only once.");
             
             var container = new Container();
@@ -258,7 +258,7 @@ namespace QuestPDF.Fluent
         /// </remarks>
         public IContainer Content()
         {
-            if (Page.Content != Empty.Instance)
+            if (Page.Content is not Empty)
                 throw new DocumentComposeException("The 'Page.Content' layer has already been defined. Please call this method only once.");
             
             var container = new Container();
@@ -274,7 +274,7 @@ namespace QuestPDF.Fluent
         /// </remarks>
         public IContainer Footer()
         {
-            if (Page.Footer != Empty.Instance)
+            if (Page.Footer is not Empty)
                 throw new DocumentComposeException("The 'Page.Footer' layer has already been defined. Please call this method only once.");
             
             var container = new Container();