@@ -42,6 +42,7 @@ source product.
42424343*/
4444using System ;
45+ using iText . IO . Util ;
4546using iText . Layout . Properties ;
4647
4748namespace iText . Layout . Renderer
@@ -64,18 +65,7 @@ public static class AbstractRendererExtensions
6465 public static float ? GetPropertyAsFloat ( this AbstractRenderer renderer , int property )
6566 {
6667 Object value = renderer . GetProperty < Object > ( property ) ;
67- return ( value is sbyte
68- || value is byte
69- || value is short
70- || value is ushort
71- || value is int
72- || value is uint
73- || value is long
74- || value is ulong
75- || value is float
76- || value is double
77- || value is decimal )
78- ? Convert . ToSingle ( value ) : ( float ? ) null ;
68+ return NumberUtil . AsFloat ( value ) ;
7969 }
8070
8171 /// <summary>Returns a property with a certain key, as a floating point value.</summary>
@@ -90,20 +80,8 @@ public static class AbstractRendererExtensions
9080 /// </returns>
9181 public static float ? GetPropertyAsFloat ( this AbstractRenderer renderer , int property , float ? defaultValue )
9282 {
93-
9483 Object value = renderer . GetProperty < Object > ( property , defaultValue ) ;
95- return ( value is sbyte
96- || value is byte
97- || value is short
98- || value is ushort
99- || value is int
100- || value is uint
101- || value is long
102- || value is ulong
103- || value is float
104- || value is double
105- || value is decimal )
106- ? Convert . ToSingle ( value ) : ( float ? ) null ;
84+ return NumberUtil . AsFloat ( value ) ;
10785 }
10886
10987 /// <summary>Returns a property with a certain key, as an integer value.</summary>
@@ -118,18 +96,7 @@ public static class AbstractRendererExtensions
11896 public static int ? GetPropertyAsInteger ( this AbstractRenderer renderer , int property )
11997 {
12098 Object value = renderer . GetProperty < Object > ( property ) ;
121- return ( value is sbyte
122- || value is byte
123- || value is short
124- || value is ushort
125- || value is int
126- || value is uint
127- || value is long
128- || value is ulong
129- || value is float
130- || value is double
131- || value is decimal )
132- ? Convert . ToInt32 ( value ) : ( int ? ) null ;
99+ return NumberUtil . AsInteger ( value ) ;
133100 }
134101 }
135102}
0 commit comments