This commit is contained in:
sunkaixuan
2017-09-28 15:05:47 +08:00
parent 9a4a930522
commit 31261605d9
11 changed files with 32 additions and 23 deletions

View File

@@ -23,5 +23,14 @@ namespace SqlSugar
/// Default SystemTable,If you do not have system table permissions, use attribute /// Default SystemTable,If you do not have system table permissions, use attribute
/// </summary> /// </summary>
public InitKeyType InitKeyType = InitKeyType.SystemTable; public InitKeyType InitKeyType = InitKeyType.SystemTable;
/// <summary>
///
/// </summary>
public ConfigureServices ConfigureExternalServices { get; set; }
}
public class ConfigureServices
{
public ISerializeManager SerializeManager { get; set; }
} }
} }

View File

@@ -8,7 +8,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SqlSugar namespace SqlSugar
{ {
public class ContextMethods : IRewritableMethods public class ContextMethods : IContextMethods
{ {
#region DataReader #region DataReader
@@ -263,7 +263,7 @@ namespace SqlSugar
#endregion #endregion
#region Cache #region Cache
public ICacheManager<T> GetCacheInstance<T>() public ICacheService<T> GetCacheInstance<T>()
{ {
return ReflectionInoCache<T>.GetInstance(); return ReflectionInoCache<T>.GetInstance();
} }

View File

@@ -356,13 +356,13 @@ namespace SqlSugar
#endregion #endregion
#region Services #region Services
public static ICacheManager<V> GetCacheInstance<V>() public static ICacheService<V> GetCacheInstance<V>()
{ {
return ReflectionInoCache<V>.GetInstance(); return ReflectionInoCache<V>.GetInstance();
} }
public static ISerializeManager GetSerializeInstance() public static ISerializeManager GetSerializeInstance()
{ {
return SerializeManager.GetInstance(); return SerializeService.GetInstance();
} }
#endregion #endregion
} }

View File

@@ -25,7 +25,7 @@ namespace SqlSugar
protected EntityMaintenance _EntityProvider; protected EntityMaintenance _EntityProvider;
protected IAdo _Ado; protected IAdo _Ado;
protected ILambdaExpressions _LambdaExpressions; protected ILambdaExpressions _LambdaExpressions;
protected IRewritableMethods _RewritableMethods; protected IContextMethods _RewritableMethods;
protected IDbMaintenance _DbMaintenance; protected IDbMaintenance _DbMaintenance;
protected QueryFilterProvider _QueryFilterProvider; protected QueryFilterProvider _QueryFilterProvider;
protected SimpleClient _SimpleClient; protected SimpleClient _SimpleClient;

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace SqlSugar namespace SqlSugar
{ {
public interface ICacheManager<V> public interface ICacheService<V>
{ {
V this[string key] { get; } V this[string key] { get; }
void Add(string key, V value); void Add(string key, V value);
@@ -12,6 +12,6 @@ namespace SqlSugar
V Get(string key); V Get(string key);
IEnumerable<string> GetAllKey(); IEnumerable<string> GetAllKey();
void Remove(string key); void Remove(string key);
V GetOrCreate(string cacheKey, Func<ICacheManager<V>, string, V> successAction, Func<ICacheManager<V>, string, V> errorAction); V GetOrCreate(string cacheKey, Func<ICacheService<V>, string, V> successAction, Func<ICacheService<V>, string, V> errorAction);
} }
} }

View File

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace SqlSugar namespace SqlSugar
{ {
public interface IRewritableMethods public interface IContextMethods
{ {
ExpandoObject DataReaderToExpandoObject(IDataReader reader); ExpandoObject DataReaderToExpandoObject(IDataReader reader);
List<ExpandoObject> DataReaderToExpandoObjectList(IDataReader reader); List<ExpandoObject> DataReaderToExpandoObjectList(IDataReader reader);
@@ -18,7 +18,7 @@ namespace SqlSugar
T TranslateCopy<T>(T sourceObject); T TranslateCopy<T>(T sourceObject);
SqlSugarClient CopyContext(SqlSugarClient context, bool isCopyEvents = false); SqlSugarClient CopyContext(SqlSugarClient context, bool isCopyEvents = false);
dynamic DataTableToDynamic(DataTable table); dynamic DataTableToDynamic(DataTable table);
ICacheManager<T> GetCacheInstance<T>(); ICacheService<T> GetCacheInstance<T>();
void RemoveCacheAll(); void RemoveCacheAll();
void RemoveCacheAll<T>(); void RemoveCacheAll<T>();
void RemoveCache<T>(string key); void RemoveCache<T>(string key);

View File

@@ -5,7 +5,7 @@ using System.Text;
namespace SqlSugar namespace SqlSugar
{ {
public interface ISerializeManager public interface ISerializeService
{ {
string SerializeObject(object value); string SerializeObject(object value);
T DeserializeObject<T>(string value); T DeserializeObject<T>(string value);

View File

@@ -6,7 +6,7 @@ using System.Collections;
using System.Linq.Expressions; using System.Linq.Expressions;
namespace SqlSugar namespace SqlSugar
{ {
public class ReflectionInoCache<V> : ICacheManager<V> public class ReflectionInoCache<V> : ICacheService<V>
{ {
readonly System.Collections.Concurrent.ConcurrentDictionary<string, V> InstanceCache = new System.Collections.Concurrent.ConcurrentDictionary<string, V>(); readonly System.Collections.Concurrent.ConcurrentDictionary<string, V> InstanceCache = new System.Collections.Concurrent.ConcurrentDictionary<string, V>();
private static ReflectionInoCache<V> _instance = null; private static ReflectionInoCache<V> _instance = null;
@@ -76,7 +76,7 @@ namespace SqlSugar
return this.InstanceCache.Keys; return this.InstanceCache.Keys;
} }
public V GetOrCreate(string cacheKey, Func<ICacheManager<V>, string, V> successAction, Func<ICacheManager<V>, string, V> errorAction) public V GetOrCreate(string cacheKey, Func<ICacheService<V>, string, V> successAction, Func<ICacheService<V>, string, V> errorAction)
{ {
var cm = ReflectionInoCache<V>.GetInstance(); var cm = ReflectionInoCache<V>.GetInstance();
if (cm.ContainsKey(cacheKey)) return successAction(cm, cacheKey); if (cm.ContainsKey(cacheKey)) return successAction(cm, cacheKey);

View File

@@ -6,16 +6,16 @@ using System.Text;
namespace SqlSugar namespace SqlSugar
{ {
public class SerializeManager:ISerializeManager public class SerializeService:ISerializeService
{ {
private static SerializeManager _instance = null; private static SerializeService _instance = null;
private static readonly object _instanceLock = new object(); private static readonly object _instanceLock = new object();
public static SerializeManager GetInstance() { public static SerializeService GetInstance() {
if (_instance == null) if (_instance == null)
lock (_instanceLock) lock (_instanceLock)
if (_instance == null) if (_instance == null)
{ {
_instance = new SerializeManager(); _instance = new SerializeService();
} }
return _instance; return _instance;
} }

View File

@@ -93,11 +93,11 @@
<Compile Include="ExpressionsToSql\Subquery\SubResolve.cs" /> <Compile Include="ExpressionsToSql\Subquery\SubResolve.cs" />
<Compile Include="ExpressionsToSql\Subquery\SubTools.cs" /> <Compile Include="ExpressionsToSql\Subquery\SubTools.cs" />
<Compile Include="Infrastructure\DependencyManagement.cs" /> <Compile Include="Infrastructure\DependencyManagement.cs" />
<Compile Include="Interface\ISerializeManager.cs" /> <Compile Include="Interface\ISerializeService.cs" />
<Compile Include="Realization\Oracle\Deleteable\OracleDeleteable.cs" /> <Compile Include="Realization\Oracle\Deleteable\OracleDeleteable.cs" />
<Compile Include="Realization\Oracle\Insertable\OracleInsertable.cs" /> <Compile Include="Realization\Oracle\Insertable\OracleInsertable.cs" />
<Compile Include="Realization\Oracle\Updateable\OracleUpdateable.cs" /> <Compile Include="Realization\Oracle\Updateable\OracleUpdateable.cs" />
<Compile Include="Utilities\SerializeManager.cs" /> <Compile Include="Services\SerializeService.cs" />
<Compile Include="Utilities\ReflectionExtensions.cs" /> <Compile Include="Utilities\ReflectionExtensions.cs" />
<Compile Include="Realization\MySql\CodeFirst\MySqlCodeFirst.cs" /> <Compile Include="Realization\MySql\CodeFirst\MySqlCodeFirst.cs" />
<Compile Include="Realization\MySql\DbFirst\MySqlDbFirst.cs" /> <Compile Include="Realization\MySql\DbFirst\MySqlDbFirst.cs" />
@@ -134,7 +134,7 @@
<Compile Include="Enum\DbObjectType.cs" /> <Compile Include="Enum\DbObjectType.cs" />
<Compile Include="Enum\ProperyType.cs" /> <Compile Include="Enum\ProperyType.cs" />
<Compile Include="Utilities\FileHelper.cs" /> <Compile Include="Utilities\FileHelper.cs" />
<Compile Include="Interface\ICacheManager.cs" /> <Compile Include="Interface\ICacheService.cs" />
<Compile Include="Entities\DbResult.cs" /> <Compile Include="Entities\DbResult.cs" />
<Compile Include="Enum\InitKeyType.cs" /> <Compile Include="Enum\InitKeyType.cs" />
<Compile Include="Interface\IFilter.cs" /> <Compile Include="Interface\IFilter.cs" />
@@ -160,7 +160,7 @@
<Compile Include="Abstract\SqlBuilderProvider\UpdateBuilder.cs" /> <Compile Include="Abstract\SqlBuilderProvider\UpdateBuilder.cs" />
<Compile Include="Abstract\SqlBuilderProvider\SqlBuilderAccessory.cs" /> <Compile Include="Abstract\SqlBuilderProvider\SqlBuilderAccessory.cs" />
<Compile Include="Abstract\SqlBuilderProvider\SqlBuilderProvider.cs" /> <Compile Include="Abstract\SqlBuilderProvider\SqlBuilderProvider.cs" />
<Compile Include="Utilities\CacheManager.cs" /> <Compile Include="Services\CacheService.cs" />
<Compile Include="Utilities\Check.cs" /> <Compile Include="Utilities\Check.cs" />
<Compile Include="Utilities\DbExtensions.cs" /> <Compile Include="Utilities\DbExtensions.cs" />
<Compile Include="Utilities\ErrorMessage.cs" /> <Compile Include="Utilities\ErrorMessage.cs" />
@@ -239,7 +239,7 @@
<Compile Include="Interface\IQueryable.cs" /> <Compile Include="Interface\IQueryable.cs" />
<Compile Include="Interface\IDMLBuilder.cs" /> <Compile Include="Interface\IDMLBuilder.cs" />
<Compile Include="Interface\ISqlBuilder.cs" /> <Compile Include="Interface\ISqlBuilder.cs" />
<Compile Include="Interface\IRewritableMethods.cs" /> <Compile Include="Interface\IContextMethods.cs" />
<Compile Include="Interface\IUpdateable.cs" /> <Compile Include="Interface\IUpdateable.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Infrastructure\SqlSugarAccessory.cs" /> <Compile Include="Infrastructure\SqlSugarAccessory.cs" />

View File

@@ -68,12 +68,12 @@ namespace SqlSugar
#region Util Methods #region Util Methods
[Obsolete("Use SqlSugarClient.Utilities")] [Obsolete("Use SqlSugarClient.Utilities")]
public virtual IRewritableMethods RewritableMethods public virtual IContextMethods RewritableMethods
{ {
get { return this.Utilities; } get { return this.Utilities; }
set { this.Utilities = value; } set { this.Utilities = value; }
} }
public virtual IRewritableMethods Utilities public virtual IContextMethods Utilities
{ {
get get
{ {