/*------------------------------------------------------------------
|
-- COPYRIGHT (C) 2010-2012 PFC
|
-- ALL RIGHTS RESERVED.
|
-- 汉和信息
|
-- CREATE DATE: 2010/08/05
|
-- CREATE MAN: 姜新军
|
-- 业务逻辑层基类
|
-- MODIFY HISTORY:
|
-- MODIFY DATE:
|
-- MODIFY MAN:
|
-- MODIFY DESC:
|
-- MODIFY DATE:
|
-- MODIFY MAN:
|
-- MODIFY DESC:
|
---------------------------------------------------------------------*/
|
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using HW.DAL;
|
|
namespace HW.BLL
|
{
|
/// <summary>
|
/// 业务逻辑层基类
|
/// </summary>
|
public abstract class BaseBLL
|
{
|
private Dictionary<Type, object> cacheInstance;
|
|
internal Dictionary<Type, object> CacheInstance
|
{
|
get
|
{
|
if (cacheInstance == null)
|
{
|
cacheInstance = new Dictionary<Type, object>();
|
}
|
return cacheInstance;
|
}
|
}
|
|
internal T CreateDAL<T>()
|
where T : BaseDAL, new()
|
{
|
return CreateDAL<T>(true);
|
}
|
|
internal T CreateDAL<T>(bool isUseCache)
|
where T : BaseDAL, new()
|
{
|
if (!isUseCache)
|
{
|
return DAOManager.Create<T>();
|
}
|
|
Type type = typeof(T);
|
|
if (!CacheInstance.ContainsKey(type))
|
{
|
CacheInstance.Add(type, DAOManager.Create<T>());
|
}
|
|
return CacheInstance[type] as T;
|
}
|
}
|
}
|