コード例 #1
0
            public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
            {
                User user = input.Inputs[0] as User;

                if (user.Password.Length < 10)
                {
                    return(input.CreateExceptionMethodReturn(new Exception("密码长度不能小于10位")));
                }
                Console.WriteLine("参数检测无误");

                IMethodReturn methodReturn = getNext.Invoke().Invoke(input, getNext);

                return(methodReturn);
            }
コード例 #2
0
ファイル: AOPBasedUnity.cs プロジェクト: ewin66/CSharp-Study
        }                             //决定方法的执行顺序

        public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
        {
            //input是传入的参数
            CourseOrder order = input.Inputs[0] as CourseOrder;

            //校验过程
            if (order.StudentId.ToString().Length < 5)
            {
                return(input.CreateExceptionMethodReturn(new Exception("学员学号不能小于5位!")));
            }
            if (order.CoursePrice < 0)
            {
                return(input.CreateExceptionMethodReturn(new Exception("课程价格不能小于0!")));
            }
            Console.WriteLine("实体数据校验成功!");

            //前进到下一个注入的行为并返回结果
            return(getNext.Invoke().Invoke(input, getNext)); //简化写法:getNext()(input, getNext)
        }
コード例 #3
0
        public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
        {
            /////自定义代码部分 开始  这部分的代码 会在方法UserProcessor.RegUser 执行前执行
            Users user = input.Inputs[0] as Users;

            if (user.Password.Length < 10)
            {
                return(input.CreateExceptionMethodReturn(new Exception("密码长度不能小于10位")));
            }
            Console.WriteLine("参数检测无误");

            /////自定义代码部分 结束
            IMethodReturn methodReturn = getNext.Invoke().Invoke(input, getNext);

            /////自定义代码部分 开始  这部分的代码 会在方法UserProcessor.RegUser 执行后执行
            /////这里可以写方法
            /////自定义代码部分 结束

            return(methodReturn);
        }
コード例 #4
0
 public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
 {
     InterceptionCount++;
     return(getNext.Invoke().Invoke(input, getNext));
 }
コード例 #5
0
 public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
 {
     InterceptionCount++;
     return getNext.Invoke().Invoke(input, getNext);
 }