62,266
社区成员
发帖
与我相关
我的任务
分享
BLL
引用DALFactory
B_News.cs
using DALFactory;
using Model;
namespace BLL
{
public class B_News
{
private INews dal = DataAccess.CreateNews();
public bool Exists(int NewsID)
{
this.dal.Exists(NewsID);
//return false;
}
}
===============
DALFactory
引用Model
DataAccess.cs
namespace DALFactory
{
public sealed class DataAccess
{
private readonly static string path = "SQLServerDAL";
private DataAccess()
{ }
public static INews CreateNews()
{
string TypeName = path+".News";
return (INews)Assembly.Load(path).CreateInstance(TypeName);
}
}
}
INews.cs
namespace DALFactory
{
/// <summary>
/// 接口层INews 的摘要说明。
/// </summary>
public interface INews
{
#region 成员方法
/// <summary>
/// 是否存在该记录
/// </summary>
bool Exists(int NewsID);
}
}
==================
SQLServerDAL
引用DALFactory
News.cs
namespace SQLServerDAL
{
public class News : INews
{
public bool Exists(int ID)
{
return false;
}
}
}
public bool Exists(int NewsID)
{
this.dal.Exists(NewsID);
//return false;
}
public bool Exists(int NewsID)
{
this.dal.Exists(NewsID);
//return false;
}