コード例 #1
0
 public static AOP ProcessAsync(this AOP aspect, Action completeCallback)
 {
     return(aspect.Combine(process => process.BeginInvoke(asyncresult =>
     {
         process.EndInvoke(asyncresult); completeCallback();
     }, null)));
 }
コード例 #2
0
 public static AOP Delay(this AOP aopify, int milliseconds)
 {
     return(aopify.Combine(process =>
     {
         System.Threading.Thread.Sleep(milliseconds);
         process();
     }));
 }
コード例 #3
0
 public static AOP Log(this AOP aopify, string beforeMessage, string afterMessage)
 {
     return(aopify.Combine(process =>
     {
         aopify.Logger.Logger.Info(beforeMessage);
         process();
         aopify.Logger.Logger.Info(afterMessage);
     }));
 }
コード例 #4
0
 public static AOP While(this AOP aopify, Func <bool> test)
 {
     return(aopify.Combine(process =>
     {
         while (test())
         {
             process();
         }
     }));
 }
コード例 #5
0
 public static AOP Log(this AOP aopify, MethodBase currentMethod)
 {
     return(aopify.Combine(process =>
     {
         aopify.Logger.CurrentMethod = currentMethod;
         aopify.Logger.Logger.Info(
             "START type :{0}, method :{1}".FormatWith(aopify.Logger.Target.Name, currentMethod == null ? process.Method.Name : currentMethod.Name));
         process();
         aopify.Logger.Logger.Info("END type :{0}, method :{1}".FormatWith(aopify.Logger.Target.Name, currentMethod == null ? process.Method.Name : currentMethod.Name));
     }));
 }
コード例 #6
0
        public static AOP WhenTrue(this AOP aopify, params Func <bool>[] conditions)
        {
            return(aopify.Combine(process =>
            {
                if (conditions.Any(condition => !condition()))
                {
                    return;
                }

                process();
            }));
        }
コード例 #7
0
        public static AOP Until(this AOP aopify, Func <bool> test)
        {
            return(aopify.Combine(process =>
            {
                while (!test())
                {
                    ;
                }

                process();
            }));
        }
コード例 #8
0
 public static AOP HowLong(this AOP aopify)
 {
     return(aopify.Combine(process =>
     {
         DateTime start = DateTime.Now;
         aopify.Logger.Logger.Info("Start Time : {0}, Method Name : {1}".FormatWith(start, aopify.Logger.CurrentMethod.Name));
         process();
         DateTime end = DateTime.Now;
         TimeSpan duration = end - start;
         aopify.Logger.Logger.Info("End Time : {0}, Method Name :{1}, TotalMs: {2}".FormatWith(end, aopify.Logger.CurrentMethod.Name, duration.TotalMilliseconds));
     }));
 }
コード例 #9
0
 public static AOP HowLong(this AOP aopify, string startMessage, string endMessage)
 {
     return(aopify.Combine(process =>
     {
         DateTime start = DateTime.Now;
         aopify.Logger.Logger.Info("{0} {1} Method Name : {2}".FormatWith(startMessage, start, aopify.Logger.CurrentMethod.Name));
         process();
         DateTime end = DateTime.Now;
         TimeSpan duration = end - start;
         aopify.Logger.Logger.Info("{0} : End Time :{1} , Method Name: {2}".FormatWith(endMessage, end, aopify.Logger.CurrentMethod.Name));
     }));
 }
コード例 #10
0
 public static AOP Catch(this AOP aopify, Action <Exception> catchAction)
 {
     return(aopify.Combine(process =>
     {
         try
         {
             process();
         }
         catch (Exception exception)
         {
             catchAction(exception);
         }
     }));
 }
コード例 #11
0
 public static AOP CatchAndThrow(this AOP aspect, Action <Exception> catchAction)
 {
     return(aspect.Combine(process =>
     {
         try
         {
             process();
         }
         catch (Exception exception)
         {
             catchAction(exception);
             throw;
         }
     }));
 }
コード例 #12
0
 public static AOP After(this AOP aopify, Action afterAction)
 {
     aopify.AfterAction = afterAction;
     return(aopify);
 }
コード例 #13
0
 public static AOP Before(this AOP aopify, Action beforeAction)
 {
     aopify.BeforeAction = beforeAction;
     return(aopify);
 }
コード例 #14
0
 public static AOP WithTransaction(this AOP aspect, Action completeCallback, Action rollbackCallback, TransactionScopeOption transactionScopeOption = TransactionScopeOption.Required)
 {
     return(aspect.Combine(process => InnerTransactionInvoker(completeCallback, rollbackCallback, new TransactionOptions(), transactionScopeOption, process)));
 }
コード例 #15
0
 public static AOP WithTransaction(this AOP aspect, TransactionOptions transactionOptions, TransactionScopeOption transactionScopeOption = TransactionScopeOption.Required)
 {
     return(aspect.Combine(process => InnerTransactionInvoker(null, null, transactionOptions, transactionScopeOption, process)));
 }
コード例 #16
0
 public static AOP ProcessAsync(this AOP aspect)
 {
     return(aspect.Combine(process => process.BeginInvoke(process.EndInvoke, null)));
 }