コード例 #1
0
 public override void OnInvoke(MethodInterceptionArgs args)
 {
     LoggingHelper.Writelog("Starting transaction");
     using (var scope = new TransactionScope())
     {
         var retries   = 3;
         var succeeded = false;
         while (!succeeded)
         {
             try
             {
                 args.Proceed();//包含了被调用方法传递过来的参数了
                 scope.Complete();
                 succeeded = true;
             }
             catch
             {
                 if (retries >= 0)
                 {
                     retries--;
                 }
                 else
                 {
                     throw;
                 }
             }
         }
     }
     LoggingHelper.Writelog("Transaction complete");
 }
コード例 #2
0
ファイル: ExceptionAspect.cs プロジェクト: benagui/CSharp
 public override void OnException(MethodExecutionArgs args)
 {
     if (Exceptions.Handle(args.Exception))
     {
         args.FlowBehavior = FlowBehavior.Continue;
     }
     args.FlowBehavior = FlowBehavior.ThrowException;
     LoggingHelper.Writelog("exception:" + args.Exception);
 }
コード例 #3
0
        public override void OnEntry(MethodExecutionArgs eventArgs)
        {
            string defaultLog = string.Format("{0} : Entry at {1}", eventArgs.Method.Name, DateTime.Now);

            LoggingHelper.Writelog(defaultLog);
            foreach (var argument in eventArgs.Arguments)
            {
                if (argument.GetType() == typeof(int))
                {
                }
            }
        }
コード例 #4
0
        public override void OnSuccess(MethodExecutionArgs eventArgs)
        {
            string defaultLog = string.Format("{0} : Success at {1}", eventArgs.Method.Name, DateTime.Now);

            LoggingHelper.Writelog(defaultLog);
        }