DALFactory/DataAccess.cs
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Reflection;
using System.Configuration;
namespace CAI.SHOP.DALFactory
{
/// <summary>
/// Abstract Factory pattern to create the DAL。
/// 如果在这里创建对象报错,请检查web.config里是否修改了<add key="DAL" value="Maticsoft.SQLServerDAL" />。
/// </summary>
public sealed class DataAccess
{
private static readonly string AssemblyPath = ConfigurationManager.AppSettings["DAL"];
public DataAccess()
{ }
#region CreateObject
//不使用缓存
private static object CreateObjectNoCache(string AssemblyPath,string classNamespace)
{
try
{
object objType = Assembly.Load(AssemblyPath).CreateInstance(classNamespace);
return objType;
}
catch//(System.Exception ex)
{
//string str=ex.Message;// 记录错误日志
return null;
}
}
//使用缓存
private static object CreateObject(string AssemblyPath,string classNamespace)
{
object objType = DataCache.GetCache(classNamespace);
if (objType == null)
{
try
{
objType = Assembly.Load(AssemblyPath).CreateInstance(classNamespace);
DataCache.SetCache(classNamespace, objType);// 写入缓存
}
catch//(System.Exception ex)
{
//string str=ex.Message;// 记录错误日志
}
}
return objType;
}
#endregion
#region CreateSysManage
public static CAI.SHOP.IDAL.ISysManage CreateSysManage()
{
//方式1
//return (CAI.SHOP.IDAL.ISysManage)Assembly.Load(AssemblyPath).CreateInstance(AssemblyPath+".SysManage");
//方式2
string classNamespace = AssemblyPath+".SysManage";
后面还有 200 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。