@@ -97,7 +97,8 @@ public Document() : this(text.PageSize.A4)
9797 /// Constructs a new Document-object.
9898 /// </summary>
9999 /// <param name="pageSize">the pageSize</param>
100- public Document ( Rectangle pageSize ) : this ( pageSize , 36 , 36 , 36 , 36 )
100+ public Document ( Rectangle pageSize ) : this ( pageSize , marginLeft : 36 , marginRight : 36 , marginTop : 36 ,
101+ marginBottom : 36 )
101102 {
102103 }
103104
@@ -227,6 +228,7 @@ public virtual HeaderFooter Footer
227228 set
228229 {
229230 footer = value ;
231+
230232 foreach ( var listener in _listeners )
231233 {
232234 listener . Footer = value ;
@@ -243,6 +245,7 @@ public virtual HeaderFooter Header
243245 set
244246 {
245247 header = value ;
248+
246249 foreach ( var listener in _listeners )
247250 {
248251 listener . Header = value ;
@@ -259,6 +262,7 @@ public virtual int PageCount
259262 set
260263 {
261264 PageNumber = value ;
265+
262266 foreach ( var listener in _listeners )
263267 {
264268 listener . PageCount = value ;
@@ -280,17 +284,17 @@ public virtual bool Add(IElement element)
280284
281285 if ( IsDocumentClose )
282286 {
283- throw new DocumentException ( "The document has been closed. You can't add any Elements." ) ;
287+ throw new DocumentException ( message : "The document has been closed. You can't add any Elements." ) ;
284288 }
285289
286290 if ( ! IsDocumentOpen && element . IsContent ( ) )
287291 {
288- throw new DocumentException ( "The document is not open yet; you can only add Meta information." ) ;
292+ throw new DocumentException ( message : "The document is not open yet; you can only add Meta information." ) ;
289293 }
290294
291295 var success = false ;
292- var number = element as ChapterAutoNumber ;
293- if ( number != null )
296+
297+ if ( element is ChapterAutoNumber number )
294298 {
295299 Chapternumber = number . SetAutomaticNumber ( Chapternumber ) ;
296300 }
@@ -300,10 +304,10 @@ public virtual bool Add(IElement element)
300304 success |= listener . Add ( element ) ;
301305 }
302306
303- var largeElement = element as ILargeElement ;
304- if ( largeElement != null )
307+ if ( element is ILargeElement largeElement )
305308 {
306309 var e = largeElement ;
310+
307311 if ( ! e . ElementComplete )
308312 {
309313 e . FlushContent ( ) ;
@@ -385,6 +389,7 @@ public virtual void Open()
385389 public virtual void ResetFooter ( )
386390 {
387391 footer = null ;
392+
388393 foreach ( var listener in _listeners )
389394 {
390395 listener . ResetFooter ( ) ;
@@ -397,6 +402,7 @@ public virtual void ResetFooter()
397402 public virtual void ResetHeader ( )
398403 {
399404 header = null ;
405+
400406 foreach ( var listener in _listeners )
401407 {
402408 listener . ResetHeader ( ) ;
@@ -409,6 +415,7 @@ public virtual void ResetHeader()
409415 public virtual void ResetPageCount ( )
410416 {
411417 PageNumber = 0 ;
418+
412419 foreach ( var listener in _listeners )
413420 {
414421 listener . ResetPageCount ( ) ;
@@ -425,6 +432,7 @@ public virtual void ResetPageCount()
425432 public virtual bool SetMarginMirroring ( bool marginMirroring )
426433 {
427434 MarginMirroring = marginMirroring ;
435+
428436 foreach ( var listener in _listeners )
429437 {
430438 listener . SetMarginMirroring ( marginMirroring ) ;
@@ -444,6 +452,7 @@ public virtual bool SetMarginMirroring(bool marginMirroring)
444452 public virtual bool SetMarginMirroringTopBottom ( bool marginMirroringTopBottom )
445453 {
446454 MarginMirroringTopBottom = marginMirroringTopBottom ;
455+
447456 foreach ( var listener in _listeners )
448457 {
449458 listener . SetMarginMirroringTopBottom ( marginMirroringTopBottom ) ;
@@ -466,6 +475,7 @@ public virtual bool SetMargins(float marginLeft, float marginRight, float margin
466475 RightMargin = marginRight ;
467476 TopMargin = marginTop ;
468477 BottomMargin = marginBottom ;
478+
469479 foreach ( var listener in _listeners )
470480 {
471481 listener . SetMargins ( marginLeft , marginRight , marginTop , marginBottom ) ;
@@ -482,6 +492,7 @@ public virtual bool SetMargins(float marginLeft, float marginRight, float margin
482492 public virtual bool SetPageSize ( Rectangle pageSize )
483493 {
484494 PageSize = pageSize ;
495+
485496 foreach ( var listener in _listeners )
486497 {
487498 listener . SetPageSize ( pageSize ) ;
@@ -509,9 +520,9 @@ public void Dispose()
509520 /// Adds the current date and time to a Document.
510521 /// </summary>
511522 /// <returns>true if successful, false otherwise</returns>
512- public bool AddCreationDate ( ) =>
513- Add ( new Meta ( Element . CREATIONDATE ,
514- DateTime . Now . ToString ( "ddd MMM dd HH:mm:ss zzz yyyy" , CultureInfo . InvariantCulture ) ) ) ;
523+ public bool AddCreationDate ( )
524+ => Add ( new Meta ( Element . CREATIONDATE ,
525+ DateTime . Now . ToString ( format : "ddd MMM dd HH:mm:ss zzz yyyy" , CultureInfo . InvariantCulture ) ) ) ;
515526
516527 /// <summary>
517528 /// Adds the creator to a Document.
@@ -524,10 +535,7 @@ public bool AddCreationDate() =>
524535 /// Adds a IDocListener to the Document.
525536 /// </summary>
526537 /// <param name="listener">the new IDocListener</param>
527- public void AddDocListener ( IDocListener listener )
528- {
529- _listeners . Add ( listener ) ;
530- }
538+ public void AddDocListener ( IDocListener listener ) => _listeners . Add ( listener ) ;
531539
532540 /// <summary>
533541 /// Adds a user defined header to the document.
@@ -611,8 +619,5 @@ public void AddDocListener(IDocListener listener)
611619 /// Removes a IDocListener from the Document.
612620 /// </summary>
613621 /// <param name="listener">the IDocListener that has to be removed.</param>
614- public void RemoveIDocListener ( IDocListener listener )
615- {
616- _listeners . Remove ( listener ) ;
617- }
622+ public void RemoveIDocListener ( IDocListener listener ) => _listeners . Remove ( listener ) ;
618623}
0 commit comments