11using System ;
22using System . Collections . Generic ;
3+ using System . Globalization ;
34using System . Linq ;
45using System . Reflection ;
56using Codeaddicts . libArgument . Attributes ;
@@ -41,7 +42,7 @@ public static class ArgumentParser
4142 throw new ArgumentOutOfRangeException ( string . Format ( "Parameter of argument {0} out of range." , str ) ) ;
4243 switch ( cast . Type ) {
4344 case CastingType . Boolean :
44- var bool_result = false ;
45+ bool bool_result ;
4546 if ( ! Boolean . TryParse ( args [ index ] , out bool_result ) )
4647 throw new InvalidCastException ( string . Format ( "Can't cast parameter of argument {0} to Boolean." , str ) ) ;
4748 field . SetValue ( options , bool_result ) ;
@@ -50,41 +51,47 @@ public static class ArgumentParser
5051 field . SetValue ( options , args [ index ] ) ;
5152 return ;
5253 case CastingType . Int32 :
53- var int32_result = 0 ;
54+ int int32_result ;
5455 if ( ! Int32 . TryParse ( args [ index ] , out int32_result ) )
5556 throw new InvalidCastException ( string . Format ( "Can't cast parameter of argument {0} to Int32." , str ) ) ;
5657 field . SetValue ( options , int32_result ) ;
5758 return ;
5859 case CastingType . Int64 :
59- var int64_result = 0L ;
60+ long int64_result ;
6061 if ( ! Int64 . TryParse ( args [ index ] , out int64_result ) )
6162 throw new InvalidCastException ( string . Format ( "Can't cast parameter of argument {0} to Int64." , str ) ) ;
6263 field . SetValue ( options , int64_result ) ;
6364 return ;
6465 case CastingType . UInt32 :
65- var uint32_result = 0u ;
66+ uint uint32_result ;
6667 if ( ! UInt32 . TryParse ( args [ index ] , out uint32_result ) )
6768 throw new InvalidCastException ( string . Format ( "Can't cast parameter of argument {0} to UInt32." , str ) ) ;
6869 field . SetValue ( options , uint32_result ) ;
6970 return ;
7071 case CastingType . UInt64 :
71- var uint64_result = 0uL ;
72+ ulong uint64_result ;
7273 if ( ! UInt64 . TryParse ( args [ index ] , out uint64_result ) )
7374 throw new InvalidCastException ( string . Format ( "Can't cast parameter of argument {0} to UInt64." , str ) ) ;
7475 field . SetValue ( options , uint64_result ) ;
7576 return ;
7677 case CastingType . Long :
77- var long_result = 0L ;
78+ long long_result ;
7879 if ( ! long . TryParse ( args [ index ] , out long_result ) )
7980 throw new InvalidCastException ( string . Format ( "Can't cast parameter of argument {0} to long." , str ) ) ;
8081 field . SetValue ( options , long_result ) ;
8182 return ;
8283 case CastingType . ULong :
83- var ulong_result = 0uL ;
84+ ulong ulong_result ;
8485 if ( ! ulong . TryParse ( args [ index ] , out ulong_result ) )
8586 throw new InvalidCastException ( string . Format ( "Can't cast parameter of argument {0} to ulong." , str ) ) ;
8687 field . SetValue ( options , ulong_result ) ;
8788 return ;
89+ case CastingType . Float :
90+ float float_result ;
91+ if ( ! float . TryParse ( args [ index ] , NumberStyles . Float , CultureInfo . InvariantCulture , out float_result ) )
92+ throw new InvalidCastException ( string . Format ( "Can't cast parameter of argument {0} to float." , str ) ) ;
93+ field . SetValue ( options , float_result ) ;
94+ return ;
8895 }
8996 }
9097 }
0 commit comments