Skip to content

Commit

Permalink
格式化代码;
Browse files Browse the repository at this point in the history
  • Loading branch information
zqlovejyc committed Jul 10, 2021
1 parent 075228c commit 5ccdc25
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions SQLBuilder.Core/Extensions/ObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@ public static class ObjectExtensions
/// <param name="this">object对象</param>
/// <param name="type">type</param>
/// <returns>object</returns>
public static object ToSafeValue(this object @this, Type type)
{
return @this == null ? null : Convert.ChangeType(@this, type.GetCoreType());
}
public static object ToSafeValue(this object @this, Type type) =>
@this == null ? null : Convert.ChangeType(@this, type.GetCoreType());
#endregion

#region IsNull
Expand All @@ -140,10 +138,8 @@ public static object ToSafeValue(this object @this, Type type)
/// </summary>
/// <param name="this">object对象</param>
/// <returns>bool</returns>
public static bool IsNull(this object @this)
{
return @this == null || @this == DBNull.Value;
}
public static bool IsNull(this object @this) =>
@this == null || @this == DBNull.Value;
#endregion

#region IsNotNull
Expand All @@ -152,10 +148,8 @@ public static bool IsNull(this object @this)
/// </summary>
/// <param name="this">object对象</param>
/// <returns>bool</returns>
public static bool IsNotNull(this object @this)
{
return !@this.IsNull();
}
public static bool IsNotNull(this object @this) =>
!@this.IsNull();
#endregion

#region ToJson
Expand All @@ -164,21 +158,17 @@ public static bool IsNotNull(this object @this)
/// </summary>
/// <param name="this">待序列化的对象</param>
/// <returns>string</returns>
public static string ToJson(this object @this)
{
return JsonConvert.SerializeObject(@this);
}
public static string ToJson(this object @this) =>
JsonConvert.SerializeObject(@this);

/// <summary>
/// 对象序列化为json字符串
/// </summary>
/// <param name="this">待序列化的对象</param>
/// <param name="settings">JsonSerializerSettings配置</param>
/// <returns></returns>
public static string ToJson(this object @this, JsonSerializerSettings settings)
{
return JsonConvert.SerializeObject(@this, settings ?? new JsonSerializerSettings());
}
public static string ToJson(this object @this, JsonSerializerSettings settings) =>
JsonConvert.SerializeObject(@this, settings ?? new JsonSerializerSettings());

/// <summary>
/// 对象序列化为json字符串
Expand Down Expand Up @@ -252,10 +242,8 @@ public static T To<T>(this object @this)
/// <param name="this">实体Type类型</param>
/// <param name="repository">仓储</param>
/// <returns></returns>
public static string ToColumns(this Type @this, IRepository repository)
{
return @this.ToColumns(repository.IsEnableFormat, repository.DatabaseType);
}
public static string ToColumns(this Type @this, IRepository repository) =>
@this.ToColumns(repository.IsEnableFormat, repository.DatabaseType);

/// <summary>
/// 根据实体类型获取所有列的查询字符串
Expand Down

0 comments on commit 5ccdc25

Please sign in to comment.