コード例 #1
0
ファイル: Service.cs プロジェクト: Hengle/LexoAop
        // Leox.AopBuildTest.Service
        // Leox.AopBuildTest.Service
        //[Timing]
        // Leox.AopBuildTest.Service
        //[Log(Order = 1), Timing(Order = 12)]
        public void Say12(string words, int age)
        {
            MemberInfo method = typeof(Service).GetMethod("Say", new Type[]
            {
                typeof(string),
                typeof(int)
            });
            MethodAspectArgs methodAspectArgs = new MethodAspectArgs();

            methodAspectArgs.Argument = new object[]
            {
                (object)words,
                age
            };
            MAList mAList = new MAList();
            Log    item   = method.GetCustomAttributes(typeof(Log), false)[0] as Log;

            mAList.Add(item);
            Timing item2 = method.GetCustomAttributes(typeof(Timing), false)[0] as Timing;

            mAList.Add(item2);
            foreach (MethodAspect current in mAList)
            {
                current.OnStart(methodAspectArgs);
            }
            try
            {
                this._Say_(words, age);
            }
            catch (Exception ex)
            {
                methodAspectArgs.Exception = ex;
                foreach (MethodAspect current in mAList)
                {
                    current.OnException(methodAspectArgs);
                }
                switch ((int)mAList[0].ExceptionStrategy)
                {
                case 1:
                    throw ex;

                case 2:
                    throw;
                }
            }
            foreach (MethodAspect current in mAList)
            {
                current.OnEnd(methodAspectArgs);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: linkypi/Leox.Transaction
        //[Transactional]
        public static void TakeOrder127()
        {
            Type   arg_22_0 = typeof(Program);
            string arg_22_1 = "TakeOrder";

            Type[]                 types            = new Type[0];
            MemberInfo             method           = arg_22_0.GetMethod(arg_22_1, types);
            MethodAspectArgs       methodAspectArgs = new MethodAspectArgs();
            MAList                 mAList           = new MAList();
            TransactionalAttribute item             = method.GetCustomAttributes(typeof(TransactionalAttribute), false)[0] as TransactionalAttribute;

            mAList.Add(item);
            foreach (MethodAspect current in mAList)
            {
                current.OnStart(methodAspectArgs);
            }
            try
            {
                Program._TakeOrder_33();
                foreach (MethodAspect current in mAList)
                {
                    current.OnSuccess(methodAspectArgs);
                }
            }
            catch (Exception ex)
            {
                methodAspectArgs.Exception = ex;
                foreach (MethodAspect current in mAList)
                {
                    current.OnException(methodAspectArgs);
                }
                switch ((int)mAList[0].ExceptionStrategy)
                {
                case 1:
                    throw ex;

                case 2:
                    throw;
                }
            }
            foreach (MethodAspect current in mAList)
            {
                current.OnEnd(methodAspectArgs);
            }
        }
コード例 #3
0
        // Leox.AopBuildTest.Program
        //[Timing]
        public static void Apply12()
        {
            Type   arg_22_0 = typeof(Program);
            string arg_22_1 = "Apply";

            Type[]           types            = new Type[0];
            MemberInfo       method           = arg_22_0.GetMethod(arg_22_1, types);
            MethodAspectArgs methodAspectArgs = new MethodAspectArgs();
            MAList           mAList           = new MAList();
            Timing           item             = method.GetCustomAttributes(typeof(Timing), false)[0] as Timing;

            mAList.Add(item);
            foreach (MethodAspect current in mAList)
            {
                current.OnStart(methodAspectArgs);
            }
            try
            {
                //Program._Apply_();
                foreach (MethodAspect current in mAList)
                {
                    current.OnSuccess(methodAspectArgs);
                }
            }
            catch (Exception ex)
            {
                methodAspectArgs.Exception = ex;
                foreach (MethodAspect current in mAList)
                {
                    current.OnException(methodAspectArgs);
                }
                switch ((int)mAList[0].ExceptionStrategy)
                {
                case 1:
                    throw ex;

                case 2:
                    throw;
                }
            }
            foreach (MethodAspect current in mAList)
            {
                current.OnEnd(methodAspectArgs);
            }
        }