在面向对象的应用程序开发中,类的接口是一个很重要的概念,在.net框架中,.net不仅提供了强大的面向对象的特性,而且它也给我们提供了一系列强大的接口供我们使用,好了我们就来看看petshop3.0中的接口层,从解决方案管理器中的PetShop.IDAL命名空间中,我们可以看到几个接口:IAccount、IInventory、IItem、IOrder、IProduct、IProfile,我们以IAccount为例: //References to PetShop specific libraries //PetShop busines entity library using PetShop.Model; namespace PetShop.IDAL { /// <summary> /// Inteface for the Account DAL /// </summary> public interface IAccount { /// <summary> /// Authenticate a user /// </summary> /// <param name="userId">Unique identifier for a user</param> /// <param name="password">Password for the user</param> /// <returns>Details about the user who has just logged in</returns> AccountInfo SignIn(string userId, string password); /// <summary> /// Get a user's address stored in the database /// </summary> /// <param name="userId">Unique identifier for a user</param> /// <returns>Address information</returns> AddressInfo GetAddress(string userId); /// <summary> /// Insert an account into the database /// </summary> /// <param name="account">Account to insert</param> void Insert(AccountInfo account); /// <summary> /// Update an account in the database /// </summary> /// <param name="Account">Account information to update</param> void Update(AccountInfo Account); } }
using System;
联系客服