@@ -23,7 +23,7 @@ public sealed class HtmlConversionBehaviorBuilder
2323
2424 internal HtmlConversionBehaviorBuilder ( HtmlConversionBehaviors htmlConversionBehaviors )
2525 {
26- this . _htmlConversionBehaviors = htmlConversionBehaviors ;
26+ _htmlConversionBehaviors = htmlConversionBehaviors ;
2727 }
2828
2929 /// <summary>
@@ -34,7 +34,7 @@ internal HtmlConversionBehaviorBuilder(HtmlConversionBehaviors htmlConversionBeh
3434 /// <remarks>Prefer <see cref="SetBrowserWaitExpression" /> over waitDelay.</remarks>
3535 public HtmlConversionBehaviorBuilder SetBrowserWaitDelay ( int seconds )
3636 {
37- this . _htmlConversionBehaviors . WaitDelay = $ "{ seconds } s";
37+ _htmlConversionBehaviors . WaitDelay = $ "{ seconds } s";
3838
3939 return this ;
4040 }
@@ -49,9 +49,12 @@ public HtmlConversionBehaviorBuilder SetBrowserWaitDelay(int seconds)
4949 /// <exception cref="InvalidOperationException"></exception>
5050 public HtmlConversionBehaviorBuilder SetBrowserWaitExpression ( string expression )
5151 {
52- if ( expression . IsNotSet ( ) ) throw new InvalidOperationException ( "expression is not set" ) ;
52+ if ( expression . IsNotSet ( ) )
53+ {
54+ throw new InvalidOperationException ( "expression is not set" ) ;
55+ }
5356
54- this . _htmlConversionBehaviors . WaitForExpression = expression ;
57+ _htmlConversionBehaviors . WaitForExpression = expression ;
5558
5659 return this ;
5760 }
@@ -65,9 +68,12 @@ public HtmlConversionBehaviorBuilder SetBrowserWaitExpression(string expression)
6568 [ Obsolete ( "Deprecated in Gotenberg v8+" ) ]
6669 public HtmlConversionBehaviorBuilder SetUserAgent ( string userAgent )
6770 {
68- if ( userAgent . IsNotSet ( ) ) throw new InvalidOperationException ( "headerName is not set" ) ;
71+ if ( userAgent . IsNotSet ( ) )
72+ {
73+ throw new InvalidOperationException ( "headerName is not set" ) ;
74+ }
6975
70- this . _htmlConversionBehaviors . UserAgent = userAgent ;
76+ _htmlConversionBehaviors . UserAgent = userAgent ;
7177
7278 return this ;
7379 }
@@ -84,7 +90,7 @@ public HtmlConversionBehaviorBuilder AddAdditionalHeaders(string headerName, str
8490 {
8591 var header = string . Format ( "{0}{2}{1}" , "{" , "}" , $ "{ '"' } { headerName } { '"' } : { '"' } { headerValue } { '"' } ") ;
8692
87- return this . AddAdditionalHeaders ( JObject . Parse ( header ) ) ;
93+ return AddAdditionalHeaders ( JObject . Parse ( header ) ) ;
8894 }
8995
9096 /// <summary>
@@ -95,85 +101,42 @@ public HtmlConversionBehaviorBuilder AddAdditionalHeaders(string headerName, str
95101 /// <exception cref="InvalidOperationException"></exception>
96102 public HtmlConversionBehaviorBuilder AddAdditionalHeaders ( JObject extraHeaders )
97103 {
98- if ( extraHeaders == null ) throw new InvalidOperationException ( "extraHeaders is null" ) ;
104+ if ( extraHeaders == null )
105+ {
106+ throw new InvalidOperationException ( "extraHeaders is null" ) ;
107+ }
99108
100- this . _htmlConversionBehaviors . ExtraHeaders = extraHeaders ;
109+ _htmlConversionBehaviors . ExtraHeaders = extraHeaders ;
101110
102111 return this ;
103112 }
104113
105114 /// <summary>
106- /// Adds a cookie to store in the Chromium cookie jar.
115+ /// Adds a cookie to store in the Chromium cookie jar.
107116 /// </summary>
108117 /// <param name="cookie">The cookie to add</param>
109118 /// <returns></returns>
110119 /// <exception cref="ArgumentNullException"></exception>
111120 public HtmlConversionBehaviorBuilder AddCookie ( Cookie cookie )
112121 {
113- if ( cookie == null ) throw new ArgumentNullException ( nameof ( cookie ) ) ;
122+ if ( cookie == null )
123+ {
124+ throw new ArgumentNullException ( nameof ( cookie ) ) ;
125+ }
114126
115- this . _htmlConversionBehaviors . Cookies ??= new List < Cookie > ( ) ;
127+ _htmlConversionBehaviors . Cookies ??= new List < Cookie > ( ) ;
116128
117129 Cookie . Validate ( cookie ) ;
118130
119- this . _htmlConversionBehaviors . Cookies . Add ( cookie ) ;
131+ _htmlConversionBehaviors . Cookies . Add ( cookie ) ;
120132
121133 return this ;
122134 }
123135
124136 /// <summary>
125- /// Adds a cookie to store in the Chromium cookie jar.
126- /// </summary>
127- /// <param name="name">Cookie name</param>
128- /// <param name="value">Cookie value</param>
129- /// <param name="domain">Cookie domain</param>
130- /// <param name="path">Optional cookie path</param>
131- /// <param name="secure">Optional secure flag</param>
132- /// <param name="httpOnly">Optional HTTP-only flag</param>
133- /// <param name="sameSite">Optional SameSite attribute ("Strict", "Lax", or "None")</param>
134- /// <returns></returns>
135- public HtmlConversionBehaviorBuilder AddCookie (
136- string name ,
137- string value ,
138- string domain ,
139- string ? path = null ,
140- bool ? secure = null ,
141- bool ? httpOnly = null ,
142- string ? sameSite = null )
143- {
144- var cookie = new Cookie
145- {
146- Name = name ,
147- Value = value ,
148- Domain = domain ,
149- Path = path ,
150- Secure = secure ,
151- HttpOnly = httpOnly ,
152- SameSite = sameSite
153- } ;
154-
155- return AddCookie ( cookie ) ;
156- }
157-
158- /// <summary>
159- /// Adds multiple cookies to store in the Chromium cookie jar.
160- /// </summary>
161- /// <param name="cookies">The cookies to add</param>
162- /// <returns></returns>
163- /// <exception cref="ArgumentNullException"></exception>
164- public HtmlConversionBehaviorBuilder AddCookies ( IEnumerable < Cookie > cookies )
165- {
166- if ( cookies == null ) throw new ArgumentNullException ( nameof ( cookies ) ) ;
167-
168- this . _htmlConversionBehaviors . Cookies ??= new List < Cookie > ( ) ;
169- this . _htmlConversionBehaviors . Cookies . AddRange ( cookies ) ;
170-
171- return this ;
172- }
173-
174- /// <summary>
175- /// Sets the document metadata.
176- /// Not all metadata are writable. Consider taking a look at https://exiftool.org/TagNames/XMP.html#pdf for an (exhaustive?) list of available metadata.
137+ /// Sets the document metadata.
138+ /// Not all metadata are writable. Consider taking a look at https://exiftool.org/TagNames/XMP.html#pdf for an
139+ /// (exhaustive?) list of available metadata.
177140 /// </summary>
178141 /// <param name="dictionary"></param>
179142 /// <returns></returns>
@@ -185,16 +148,20 @@ public HtmlConversionBehaviorBuilder SetMetadata(IDictionary<string, object> dic
185148 }
186149
187150 /// <summary>
188- /// Sets the document metadata.
189- /// Not all metadata are writable. Consider taking a look at https://exiftool.org/TagNames/XMP.html#pdf for an (exhaustive?) list of available metadata.
151+ /// Sets the document metadata.
152+ /// Not all metadata are writable. Consider taking a look at https://exiftool.org/TagNames/XMP.html#pdf for an
153+ /// (exhaustive?) list of available metadata.
190154 /// </summary>
191155 /// <param name="metadata"></param>
192156 /// <returns></returns>
193157 public HtmlConversionBehaviorBuilder SetMetadata ( JObject metadata )
194158 {
195- if ( metadata == null ) throw new InvalidOperationException ( "metadata is null" ) ;
159+ if ( metadata == null )
160+ {
161+ throw new InvalidOperationException ( "metadata is null" ) ;
162+ }
196163
197- this . _htmlConversionBehaviors . MetaData = metadata ;
164+ _htmlConversionBehaviors . MetaData = metadata ;
198165
199166 return this ;
200167 }
@@ -205,7 +172,7 @@ public HtmlConversionBehaviorBuilder SetMetadata(JObject metadata)
205172 /// <returns></returns>
206173 public HtmlConversionBehaviorBuilder FailOnConsoleExceptions ( )
207174 {
208- this . _htmlConversionBehaviors . FailOnConsoleExceptions = true ;
175+ _htmlConversionBehaviors . FailOnConsoleExceptions = true ;
209176
210177 return this ;
211178 }
@@ -216,18 +183,18 @@ public HtmlConversionBehaviorBuilder FailOnConsoleExceptions()
216183 /// <returns></returns>
217184 public HtmlConversionBehaviorBuilder EmulateAsScreen ( )
218185 {
219- this . _htmlConversionBehaviors . EmulatedMediaType = "screen" ;
186+ _htmlConversionBehaviors . EmulatedMediaType = "screen" ;
220187
221188 return this ;
222189 }
223190
224191 /// <summary>
225- /// Gotenberg 8+ ONLY: Configures gotenberg to not wait for Chromium network to be idle.
192+ /// Gotenberg 8+ ONLY: Configures gotenberg to not wait for Chromium network to be idle.
226193 /// </summary>
227194 /// <returns></returns>
228195 public HtmlConversionBehaviorBuilder SkipNetworkIdleEvent ( )
229196 {
230- this . _htmlConversionBehaviors . SkipNetworkIdleEvent = true ;
197+ _htmlConversionBehaviors . SkipNetworkIdleEvent = true ;
231198
232199 return this ;
233200 }
@@ -240,9 +207,12 @@ public HtmlConversionBehaviorBuilder SkipNetworkIdleEvent()
240207 /// <exception cref="InvalidOperationException"></exception>
241208 public HtmlConversionBehaviorBuilder SetPdfFormat ( ConversionPdfFormats format )
242209 {
243- if ( format == default ) throw new InvalidOperationException ( "Invalid PDF format specified" ) ;
210+ if ( format == default )
211+ {
212+ throw new InvalidOperationException ( "Invalid PDF format specified" ) ;
213+ }
244214
245- this . _htmlConversionBehaviors . PdfFormat = format ;
215+ _htmlConversionBehaviors . PdfFormat = format ;
246216
247217 return this ;
248218 }
@@ -252,7 +222,7 @@ public HtmlConversionBehaviorBuilder SetPdfFormat(ConversionPdfFormats format)
252222 /// </summary>
253223 public HtmlConversionBehaviorBuilder SetPdfUa ( bool enablePdfUa = true )
254224 {
255- this . _htmlConversionBehaviors . EnablePdfUa = enablePdfUa ;
225+ _htmlConversionBehaviors . EnablePdfUa = enablePdfUa ;
256226
257227 return this ;
258228 }
0 commit comments