Beispiel #1
0
        public override void OnStart(MethodAspectArgs args)
        {
            Console.WriteLine("tranx start.");
            string id = Guid.NewGuid().ToString().Replace("-", "");

            this.ExceptionStrategy = Aop.ExceptionStrategy.UnThrow;

            Manager.BeginTransaction(id, IsolationLevel);
        }
Beispiel #2
0
 public override void OnStart(MethodAspectArgs args)
 {
     if (args != null && args.Argument != null)
     {
         foreach (var item in args.Argument)
         {
             Console.Write(item.ToString() + "  ");
         }
     }
     Console.WriteLine("timing start" + (args != null && args.Argument != null ? args.Argument[0].ToString() : ""));
 }
Beispiel #3
0
        // 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);
            }
        }
Beispiel #4
0
        //[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);
            }
        }
Beispiel #5
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);
            }
        }
Beispiel #6
0
 public override void OnSuccess(MethodAspectArgs args)
 {
     Console.WriteLine("log success : " + args.ReturnValue.ToString());
 }
Beispiel #7
0
 public override void OnEnd(MethodAspectArgs args)
 {
     Console.WriteLine("log end");
 }
Beispiel #8
0
 public override void OnStart(MethodAspectArgs args)
 {
     Console.WriteLine("log start");
 }
Beispiel #9
0
 public override void OnException(MethodAspectArgs args)
 {
     Console.WriteLine("log on exception: " + args.Exception.Message);
 }
Beispiel #10
0
 public override void OnSuccess(MethodAspectArgs args)
 {
     Console.WriteLine("tranx success.");
     Manager.Commit();
 }
Beispiel #11
0
 public override void OnException(MethodAspectArgs args)
 {
     Console.WriteLine("tranx exception." + args.Exception.Message);
     Manager.RollBack();
 }
Beispiel #12
0
 public override void OnEnd(MethodAspectArgs args)
 {
     Console.WriteLine("tranx end.");
 }