@@ -38,7 +38,7 @@ static CommonHelper()
38
38
/// <summary>
39
39
/// 获取或设置默认文件提供程序
40
40
/// </summary>
41
- public static IDHFileProvider DefaultFileProvider { get ; set ; }
41
+ public static IDHFileProvider ? DefaultFileProvider { get ; set ; }
42
42
43
43
#endregion
44
44
@@ -199,7 +199,7 @@ public static bool ArraysEqual<T>(T[] a1, T[] a2)
199
199
/// <param name="instance">要设置其属性的对象。</param>
200
200
/// <param name="propertyName">要设置的属性的名称。</param>
201
201
/// <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 )
203
203
{
204
204
if ( instance == null )
205
205
throw new ArgumentNullException ( nameof ( instance ) ) ;
@@ -223,10 +223,7 @@ public static void SetProperty(object instance, string propertyName, object valu
223
223
/// <param name="value">要转换的值。</param>
224
224
/// <param name="destinationType">要将值转换为的类型。</param>
225
225
/// <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 ) ;
230
227
231
228
/// <summary>
232
229
/// 将值转换为目标类型。
@@ -235,7 +232,7 @@ public static object To(object value, Type destinationType)
235
232
/// <param name="destinationType">要将值转换为的类型。</param>
236
233
/// <param name="culture">文化</param>
237
234
/// <returns>转换后的值。</returns>
238
- public static object To ( object value , Type destinationType , CultureInfo culture )
235
+ public static Object ? To ( Object ? value , Type destinationType , CultureInfo culture )
239
236
{
240
237
if ( value == null )
241
238
return null ;
@@ -265,11 +262,9 @@ public static object To(object value, Type destinationType, CultureInfo culture)
265
262
/// <param name="value">要转换的值。</param>
266
263
/// <typeparam name="T">要将值转换为的类型。</typeparam>
267
264
/// <returns>转换后的值。</returns>
268
- public static T To < T > ( object value )
269
- {
265
+ public static T ? To < T > ( Object ? value ) =>
270
266
//return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
271
- return ( T ) To ( value , typeof ( T ) ) ;
272
- }
267
+ ( T ? ) To ( value , typeof ( T ) ) ;
273
268
274
269
/// <summary>
275
270
/// 转换前端枚举
@@ -331,25 +326,25 @@ public static int GetDifferenceInYears(DateTime startDate, DateTime endDate)
331
326
}
332
327
333
328
/// <summary>
334
- /// Get private fields property value
329
+ /// 获取私有字段属性值
335
330
/// </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>
338
333
/// <returns>Value</returns>
339
- public static object GetPrivateFieldValue ( object target , string fieldName )
334
+ public static Object ? GetPrivateFieldValue ( Object target , String fieldName )
340
335
{
341
336
if ( target == null )
342
337
{
343
338
throw new ArgumentNullException ( nameof ( target ) , "The assignment target cannot be null." ) ;
344
339
}
345
340
346
- if ( string . IsNullOrEmpty ( fieldName ) )
341
+ if ( String . IsNullOrEmpty ( fieldName ) )
347
342
{
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 ) ) ;
349
344
}
350
345
351
346
var t = target . GetType ( ) ;
352
- FieldInfo fi = null ;
347
+ FieldInfo ? fi = null ;
353
348
354
349
while ( t != null )
355
350
{
0 commit comments