@@ -38,7 +38,7 @@ static CommonHelper()
3838 /// <summary>
3939 /// 获取或设置默认文件提供程序
4040 /// </summary>
41- public static IDHFileProvider DefaultFileProvider { get ; set ; }
41+ public static IDHFileProvider ? DefaultFileProvider { get ; set ; }
4242
4343 #endregion
4444
@@ -199,7 +199,7 @@ public static bool ArraysEqual<T>(T[] a1, T[] a2)
199199 /// <param name="instance">要设置其属性的对象。</param>
200200 /// <param name="propertyName">要设置的属性的名称。</param>
201201 /// <param name="value">要将属性设置为的值。</param>
202- public static void SetProperty ( object instance , string propertyName , object value )
202+ public static void SetProperty ( Object instance , String propertyName , Object ? value )
203203 {
204204 if ( instance == null )
205205 throw new ArgumentNullException ( nameof ( instance ) ) ;
@@ -223,10 +223,7 @@ public static void SetProperty(object instance, string propertyName, object valu
223223 /// <param name="value">要转换的值。</param>
224224 /// <param name="destinationType">要将值转换为的类型。</param>
225225 /// <returns>转换后的值。</returns>
226- public static object To ( object value , Type destinationType )
227- {
228- return To ( value , destinationType , CultureInfo . InvariantCulture ) ;
229- }
226+ public static Object ? To ( Object ? value , Type destinationType ) => To ( value , destinationType , CultureInfo . InvariantCulture ) ;
230227
231228 /// <summary>
232229 /// 将值转换为目标类型。
@@ -235,7 +232,7 @@ public static object To(object value, Type destinationType)
235232 /// <param name="destinationType">要将值转换为的类型。</param>
236233 /// <param name="culture">文化</param>
237234 /// <returns>转换后的值。</returns>
238- public static object To ( object value , Type destinationType , CultureInfo culture )
235+ public static Object ? To ( Object ? value , Type destinationType , CultureInfo culture )
239236 {
240237 if ( value == null )
241238 return null ;
@@ -265,11 +262,9 @@ public static object To(object value, Type destinationType, CultureInfo culture)
265262 /// <param name="value">要转换的值。</param>
266263 /// <typeparam name="T">要将值转换为的类型。</typeparam>
267264 /// <returns>转换后的值。</returns>
268- public static T To < T > ( object value )
269- {
265+ public static T ? To < T > ( Object ? value ) =>
270266 //return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
271- return ( T ) To ( value , typeof ( T ) ) ;
272- }
267+ ( T ? ) To ( value , typeof ( T ) ) ;
273268
274269 /// <summary>
275270 /// 转换前端枚举
@@ -331,25 +326,25 @@ public static int GetDifferenceInYears(DateTime startDate, DateTime endDate)
331326 }
332327
333328 /// <summary>
334- /// Get private fields property value
329+ /// 获取私有字段属性值
335330 /// </summary>
336- /// <param name="target">Target object </param>
337- /// <param name="fieldName">Field name </param>
331+ /// <param name="target">目标对象 </param>
332+ /// <param name="fieldName">字段名称 </param>
338333 /// <returns>Value</returns>
339- public static object GetPrivateFieldValue ( object target , string fieldName )
334+ public static Object ? GetPrivateFieldValue ( Object target , String fieldName )
340335 {
341336 if ( target == null )
342337 {
343338 throw new ArgumentNullException ( nameof ( target ) , "The assignment target cannot be null." ) ;
344339 }
345340
346- if ( string . IsNullOrEmpty ( fieldName ) )
341+ if ( String . IsNullOrEmpty ( fieldName ) )
347342 {
348- throw new ArgumentException ( "fieldName" , " The field name cannot be null or empty.") ;
343+ throw new ArgumentException ( "The field name cannot be null or empty." , nameof ( fieldName ) ) ;
349344 }
350345
351346 var t = target . GetType ( ) ;
352- FieldInfo fi = null ;
347+ FieldInfo ? fi = null ;
353348
354349 while ( t != null )
355350 {
0 commit comments