This commit is contained in:
sunkaixuan 2017-05-25 09:43:21 +08:00
parent f6ed271aa1
commit f9133c0fe6
4 changed files with 24 additions and 92 deletions

View File

@ -7,141 +7,80 @@ namespace SqlSugar
{
internal static class IsWhatExtensions
{
/// <summary>
/// 值在的范围?
/// </summary>
/// <param name="thisValue"></param>
/// <param name="begin">大于等于begin</param>
/// <param name="end">小于等于end</param>
/// <returns></returns>
public static bool IsInRange(this int thisValue, int begin, int end)
{
return thisValue >= begin && thisValue <= end;
}
/// <summary>
/// 值在的范围?
/// </summary>
/// <param name="thisValue"></param>
/// <param name="begin">大于等于begin</param>
/// <param name="end">小于等于end</param>
/// <returns></returns>
public static bool IsInRange(this DateTime thisValue, DateTime begin, DateTime end)
{
return thisValue >= begin && thisValue <= end;
}
/// <summary>
/// 在里面吗?
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="thisValue"></param>
/// <param name="values"></param>
/// <returns></returns>
public static bool IsIn<T>(this T thisValue, params T[] values)
{
return values.Contains(thisValue);
}
/// <summary>
/// 在里面吗?
/// </summary>
/// <param name="thisValue"></param>
/// <param name="inValues"></param>
/// <returns></returns>
public static bool IsContainsIn(this string thisValue, params string[] inValues)
{
return inValues.Any(it => thisValue.Contains(it));
}
/// <summary>
/// 是null或""?
/// </summary>
/// <returns></returns>
public static bool IsNullOrEmpty(this object thisValue)
{
if (thisValue == null || thisValue == DBNull.Value) return true;
return thisValue.ToString() == "";
}
/// <summary>
/// 是null或""?
/// </summary>
/// <returns></returns>
public static bool IsNullOrEmpty(this Guid? thisValue)
{
if (thisValue == null) return true;
return thisValue == Guid.Empty;
}
/// <summary>
/// 是null或""?
/// </summary>
/// <returns></returns>
public static bool IsNullOrEmpty(this Guid thisValue)
{
if (thisValue == null) return true;
return thisValue == Guid.Empty;
}
/// <summary>
/// 是null或""?
/// </summary>
/// <returns></returns>
public static bool IsNullOrEmpty(this IEnumerable<object> thisValue)
{
if (thisValue == null || thisValue.Count() == 0) return true;
return false;
}
/// <summary>
/// 有值?(与IsNullOrEmpty相反)
/// </summary>
/// <returns></returns>
public static bool IsValuable(this object thisValue)
{
if (thisValue == null || thisValue == DBNull.Value) return false;
return thisValue.ToString() != "";
}
/// <summary>
/// 有值?(与IsNullOrEmpty相反)
/// </summary>
/// <returns></returns>
public static bool IsValuable(this IEnumerable<object> thisValue)
{
if (thisValue == null || thisValue.Count() == 0) return false;
return true;
}
/// <summary>
/// 有值?(与IsNullOrEmpty相反)
/// </summary>
/// <returns></returns>
public static bool IsValuable(this IEnumerable<KeyValuePair<string,string>> thisValue)
{
if (thisValue == null || thisValue.Count() == 0) return false;
return true;
}
/// <summary>
/// 是零?
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static bool IsZero(this object thisValue)
{
return (thisValue == null || thisValue.ToString() == "0");
}
/// <summary>
/// 是INT?
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static bool IsInt(this object thisValue)
{
if (thisValue == null) return false;
return Regex.IsMatch(thisValue.ToString(), @"^\d+$");
}
/// <summary>
/// 不是INT?
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static bool IsNoInt(this object thisValue)
{
@ -149,23 +88,12 @@ namespace SqlSugar
return !Regex.IsMatch(thisValue.ToString(), @"^\d+$");
}
/// <summary>
/// 是金钱?
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static bool IsMoney(this object thisValue)
{
if (thisValue == null) return false;
double outValue = 0;
return double.TryParse(thisValue.ToString(), out outValue);
}
/// <summary>
/// 是GUID?
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static bool IsGuid(this object thisValue)
{
if (thisValue == null) return false;
@ -173,11 +101,6 @@ namespace SqlSugar
return Guid.TryParse(thisValue.ToString(), out outValue);
}
/// <summary>
/// 是时间?
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static bool IsDate(this object thisValue)
{
if (thisValue == null) return false;

View File

@ -5,13 +5,6 @@ using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public interface IConnectionConfig
{
string DbType { get; set; }
string ConnectionString { get; set; }
bool IsAutoCloseConnection { get; set; }
}
public class SystemTableConfig : IConnectionConfig
{
public string DbType { get; set; }

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SqlSugar
{
public interface IConnectionConfig
{
string DbType { get; set; }
string ConnectionString { get; set; }
bool IsAutoCloseConnection { get; set; }
}
}

View File

@ -58,6 +58,7 @@
<Compile Include="Abstract\InsertableProvider\InsertableProvider.cs" />
<Compile Include="Abstract\DeleteProvider\DeleteableProvider.cs" />
<Compile Include="Abstract\UpdateProvider\UpdateableProvider.cs" />
<Compile Include="Interface\IConnectionConfig.cs" />
<Compile Include="Realization\SqlServer\Core\SqlBuilder\SqlServerDeleteBuilder.cs" />
<Compile Include="Realization\SqlServer\Core\SqlBuilder\SqlServerInsertBuilder.cs" />
<Compile Include="Entities\EntityColumnInfo.cs" />