@@ -106,7 +106,15 @@ public bool ShrinkToFit
106106 public PageSize PageDimensions
107107 {
108108 get { return pageSize ; }
109- set { pageSize = value ; }
109+ set
110+ {
111+ if ( value == null )
112+ {
113+ throw new ArgumentNullException ( "PageDimensions cannot be set to null" ) ;
114+ }
115+
116+ pageSize = value ;
117+ }
110118 }
111119
112120 /// <summary>
@@ -115,7 +123,15 @@ public PageSize PageDimensions
115123 public Margins PageMargins
116124 {
117125 get { return margins ; }
118- set { margins = value ; }
126+ set
127+ {
128+ if ( value == null )
129+ {
130+ throw new ArgumentNullException ( "PageMargins cannot be set to null" ) ;
131+ }
132+
133+ margins = value ;
134+ }
119135 }
120136
121137 /// <summary>
@@ -201,15 +217,15 @@ internal Dictionary<string, object> ToDictionary()
201217 toReturn [ "shrinkToFit" ] = this . shrinkToFit ;
202218 }
203219
204- if ( this . pageSize != null && ( this . pageSize . Height != DefaultPageHeight || this . pageSize . Width != DefaultPageWidth ) )
220+ if ( this . pageSize . Height != DefaultPageHeight || this . pageSize . Width != DefaultPageWidth )
205221 {
206222 Dictionary < string , object > pageSizeDictionary = new Dictionary < string , object > ( ) ;
207223 pageSizeDictionary [ "width" ] = this . pageSize . Width ;
208224 pageSizeDictionary [ "height" ] = this . pageSize . Height ;
209225 toReturn [ "page" ] = pageSizeDictionary ;
210226 }
211227
212- if ( this . margins != null && ( this . margins . Top != DefaultMarginSize || this . margins . Bottom != DefaultMarginSize || this . margins . Left != DefaultMarginSize || this . margins . Right != DefaultMarginSize ) )
228+ if ( this . margins . Top != DefaultMarginSize || this . margins . Bottom != DefaultMarginSize || this . margins . Left != DefaultMarginSize || this . margins . Right != DefaultMarginSize )
213229 {
214230 Dictionary < string , object > marginsDictionary = new Dictionary < string , object > ( ) ;
215231 marginsDictionary [ "top" ] = this . margins . Top ;
@@ -258,6 +274,11 @@ public double Height
258274 get { return height ; }
259275 set
260276 {
277+ if ( value == null )
278+ {
279+ throw new ArgumentNullException ( "Height cannot be set to null" ) ;
280+ }
281+
261282 if ( value < 0 )
262283 {
263284 throw new ArgumentException ( "Height must be greater than or equal to zero." ) ;
@@ -275,6 +296,11 @@ public double Width
275296 get { return width ; }
276297 set
277298 {
299+ if ( value == null )
300+ {
301+ throw new ArgumentNullException ( "Width cannot be set to null" ) ;
302+ }
303+
278304 if ( value < 0 )
279305 {
280306 throw new ArgumentException ( "Width must be greater than or equal to zero." ) ;
@@ -321,6 +347,11 @@ public double Top
321347 get { return top ; }
322348 set
323349 {
350+ if ( value == null )
351+ {
352+ throw new ArgumentNullException ( "Top cannot be set to null" ) ;
353+ }
354+
324355 if ( value < 0 )
325356 {
326357 throw new ArgumentException ( "Top margin must be greater than or equal to zero." ) ;
@@ -338,6 +369,11 @@ public double Bottom
338369 get { return bottom ; }
339370 set
340371 {
372+ if ( value == null )
373+ {
374+ throw new ArgumentNullException ( "Bottom cannot be set to null" ) ;
375+ }
376+
341377 if ( value < 0 )
342378 {
343379 throw new ArgumentException ( "Bottom margin must be greater than or equal to zero." ) ;
@@ -355,6 +391,11 @@ public double Left
355391 get { return left ; }
356392 set
357393 {
394+ if ( value == null )
395+ {
396+ throw new ArgumentNullException ( "Left cannot be set to null" ) ;
397+ }
398+
358399 if ( value < 0 )
359400 {
360401 throw new ArgumentException ( "Left margin must be greater than or equal to zero." ) ;
@@ -372,6 +413,11 @@ public double Right
372413 get { return right ; }
373414 set
374415 {
416+ if ( value == null )
417+ {
418+ throw new ArgumentNullException ( "Right cannot be set to null" ) ;
419+ }
420+
375421 if ( value < 0 )
376422 {
377423 throw new ArgumentException ( "Right margin must be greater than or equal to zero." ) ;
0 commit comments