Example #1
0
 public UserController(IUserPasswordDAL userPasswordDal, IStudentDAL studentDal, EmployerSqlDAL employerDal)
     : base(userPasswordDal)
 {
     this.userPasswordDal = userPasswordDal;
     this.studentDal      = studentDal;
     this.employerDal     = employerDal;
 }
 /// <summary>
 /// Method which is injected a dependency
 /// </summary>
 /// <param name="studentDAL">Dependency injected</param>
 /// <param name="list">Student list</param>
 /// <param name="name">Student' name need to be searched</param>
 /// <returns>Student with spicific name</returns>
 public Student GetStudent(IStudentDAL studentDAL, List <Student> list, string name)
 {
     try
     {
         return(studentDAL.GetStudentByName(list, name));
     }
     catch { throw; }
 }
Example #3
0
 public StaffController(IStaffDAL staffDal, IUserPasswordDAL userPasswordDal, IStudentDAL studentDal, IEmployerDAL employerDal)
     : base(userPasswordDal)
 {
     this.staffDal        = staffDal;
     this.userPasswordDal = userPasswordDal;
     this.studentDal      = studentDal;
     this.employerDal     = employerDal;
 }
 public StudentService(IStudentDAL _db)
 {
     db = _db;
 }
Example #5
0
 public StudentManager(IStudentDAL _studentDAL)
 {
     studentDAL = _studentDAL;
 }
Example #6
0
 public StudentBL(IStudentDAL studentDAL)
 {
     _iStudentDAL = studentDAL;
 }
Example #7
0
 public StudentController ( IStudentDAL IS )
 {
     student = IS;
 }
 public StudentController(IStudentDAL studentDAL, IUserPasswordDAL userPasswordDAL)
 {
     this.studentDAL      = studentDAL;
     this.userPasswordDAL = userPasswordDAL;
 }
Example #9
0
 public StudentsController(IStudentDAL studentDAL, ICompanyDAL companyDAL, IPreferencesDAL preferencesDAL)
 {
     this.studentDAL     = studentDAL;
     this.companyDAL     = companyDAL;
     this.preferencesDAL = preferencesDAL;
 }
Example #10
0
 public StudentBLL()
 {
     dal = DALFactory.createStudentDAL();
 }
Example #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("********手写IOC容器*************");

            CustomIOCContainer container = new CustomIOCContainer();

            container.Register <IUserDAL, UserDAL>();
            container.Register <IUserBLL, UserBLL>();
            //单接口多实现
            container.Register <IMessageDAL, SmsDAL>("smsDAL");
            container.Register <IMessageDAL, EmailDAL>("emailDAL");
            container.Register <IStudentDAL, StudentDAL>();

            //解析
            IUserDAL    iuserDAL  = container.Resolve <IUserDAL>();
            IUserBLL    iuserBLL  = container.Resolve <IUserBLL>();//解析IUserBLL需要参数
            IMessageDAL ismsDAL   = container.Resolve <IMessageDAL>("smsDAL");
            IMessageDAL iemailDAL = container.Resolve <IMessageDAL>("emailDAL");

            //执行DAL方法
            iuserDAL.AddUser(new Wcs.Models.UserModel());

            //执行BLL方法
            iuserBLL.AddUser(new Wcs.Models.UserModel());

            //属性注入的方式--执行BLL方法
            iuserBLL.AddUser_Property(new Wcs.Models.UserModel());

            //方法注入的方式--执行BLL方法
            iuserBLL.AddUser_Method(new Wcs.Models.UserModel());

            //实现单接口多实现,注册或解析时要区分下字典里面的值,所以key加要shortName
            ismsDAL.Send();
            iemailDAL.Send();

            /*思考:单接口多实现如果在构造别的类的时候需要构造IMessageDAL,此时应该选择SmsDAL还是EmailDAL
             * 所以就要在构造函数里面用属性去指定shortName,用UserBLL做例子来实现
             * 在此还要引入一个新的知识点,参数也是可以打标记的(WcsParameterAttribute)
             */
            IUserBLL iuserBLL2 = container.Resolve <IUserBLL>();//解析IUserBLL需要参数

            /*
             * IOC+Aop 利用Castle手写实现
             */

            Console.WriteLine("*********************IOC+Aop 利用Castle手写实现*********************");
            IStudentDAL iStudentDAL = container.Resolve <IStudentDAL>();

            //用扩展方法实现Aop,这样对这个接口里面的所有的发方法都会前后加逻辑
            IStudentDAL istudentDAL_aop = (IStudentDAL)iStudentDAL.AOP(typeof(IStudentDAL));

            istudentDAL_aop.Study(new Wcs.Models.StudentModel()
            {
                Name = "张三"
            });
            istudentDAL_aop.Run(new Wcs.Models.StudentModel()
            {
                Name = "张三"
            });

            /*这样扩展出的Aop实现,有局限性,所有的逻辑就都会在IocIntercetor的方法里面
             * 为了更灵活,实现MVC过滤器的那样灵活,就要引入特性,请看 public static class AopExtend的AOP扩展方法
             */

            /*
             * AOP方法封装之后,可以直接和IOC融合,把CustomIOCContainer的Resolve方法返回实体的时候
             * 后面加上.AOP方法即可,这样整个框架就都支持AOP了,
             * 把上面调用AOP可以直接注释掉,在下面进行验证
             */
            iStudentDAL.Run(new Wcs.Models.StudentModel()
            {
                Name = "张三"
            });
        }
 public EmployerController(IEmployerDAL employerDal, IStudentDAL studentDAL)
 {
     this.employerDAL = employerDal;
     this.studentDAL  = studentDAL;
 }
Example #13
0
 public HomeController(IStudentDAL studentDal)
 {
     this.studentSqlDAl = studentDal;
 }
Example #14
0
 public StudentLogic(IStudentDAL dal)
 {
     this.dal = dal;
 }
Example #15
0
 public StudentBLL(IStudentDAL studentDAL)
 {
     _studentDAL = studentDAL;
 }
Example #16
0
 public HomeController(ILogger <HomeController> logger, IStudentDAL student)
 {
     _logger  = logger;
     _student = student;
 }
Example #17
0
 public StudentBLL(IStudentDAL iDAL)
 {
     this._iDAL = iDAL;
 }
Example #18
0
 public StudentBLL()
 {
     dal = DALFactory.createStudentDAL();
 }
Example #19
0
 public StudentService(IStudentDAL studentDAL, IUserDAL userDAL)
 {
     this.studentDAL = studentDAL;
     this.userDAL    = userDAL;
 }
Example #20
0
 public StudentController(IStudentDAL student)
 {
     _student = student;
 }
Example #21
0
 public StudentBLL(IStudentDAL istudentDAL)
 {
     this.istudentDAL = istudentDAL;
 }