petshop
/// <summary>
/// A business component to manage products
/// </summary>
public class Product {
// Get an instance of the Product DAL using the DALFactory
// Making this static will cache the DAL instance after the initial load private static readonly IProduct dal = PetShop
在bll層
namespace PetShop
{
/// <summary>
/// Interface for the Product DAL
/// </summary>
public interface IProduct
{
/// <summary>
/// Method to search products by category name
/// </summary>
/// <param name=
/// <returns>Interface to Model Collection Generic of search results</returns> IList<ProductInfo> GetProductsByCategory(string category);
/// <summary>
/// Method to search products by a set of keyword
/// </summary>
/// <param name=
/// <returns>Interface to Model Collection Generic of search results</returns> IList<ProductInfo> GetProductsBySearch(string[] keywords);
/// <summary>
/// Query for a product
/// </summary>
/// <param name=
/// <returns>Interface to Model ProductInfo for requested product</returns> ProductInfo GetProduct(string productId); }
這裡是定義了Product接口和他的虛方法
public class Product : IProduct {
//Static constants private const string SQL_SELECT_PRODUCTS_BY_CATEGORY =
/// <summary>
/// Query for products by category
/// </summary>
/// <param name=
/// <returns>A Generic List of ProductInfo</returns> public IList<ProductInfo> GetProductsByCategory(string category) {
IList<ProductInfo> productsByCategory = new List<ProductInfo>();
這裡是實現Product接口的類
/// <summary>
/// This class is implemented following the Abstract Factory pattern to create the DAL implementation
/// specified from the configuration file
/// </summary> public sealed class DataAccess {
// Look up the DAL implementation we should be using private static readonly string path = ConfigurationManager
public static PetShop
這裡是利用工廠模式來映射你需要你想創建哪一個
後面還有一些消息隊列MSMQMessage利用cache緩存以後達到異步處理購物車裡訂單的功能!
剛開始看應先從先從Product入口
From:http://tw.wingwit.com/Article/program/net/201311/11385.html