Example #1
0
 public static AOP ProcessAsync(this AOP aspect, Action completeCallback)
 {
     return(aspect.Combine(process => process.BeginInvoke(asyncresult =>
     {
         process.EndInvoke(asyncresult); completeCallback();
     }, null)));
 }
Example #2
0
 public static AOP Delay(this AOP aopify, int milliseconds)
 {
     return(aopify.Combine(process =>
     {
         System.Threading.Thread.Sleep(milliseconds);
         process();
     }));
 }
Example #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);
     }));
 }
Example #4
0
 public static AOP While(this AOP aopify, Func <bool> test)
 {
     return(aopify.Combine(process =>
     {
         while (test())
         {
             process();
         }
     }));
 }
Example #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));
     }));
 }
Example #6
0
        public static AOP WhenTrue(this AOP aopify, params Func <bool>[] conditions)
        {
            return(aopify.Combine(process =>
            {
                if (conditions.Any(condition => !condition()))
                {
                    return;
                }

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

                process();
            }));
        }
Example #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));
     }));
 }
Example #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));
     }));
 }
Example #10
0
 public static AOP Catch(this AOP aopify, Action <Exception> catchAction)
 {
     return(aopify.Combine(process =>
     {
         try
         {
             process();
         }
         catch (Exception exception)
         {
             catchAction(exception);
         }
     }));
 }
Example #11
0
 public static AOP CatchAndThrow(this AOP aspect, Action <Exception> catchAction)
 {
     return(aspect.Combine(process =>
     {
         try
         {
             process();
         }
         catch (Exception exception)
         {
             catchAction(exception);
             throw;
         }
     }));
 }
Example #12
0
 public static AOP After(this AOP aopify, Action afterAction)
 {
     aopify.AfterAction = afterAction;
     return(aopify);
 }
Example #13
0
 public static AOP Before(this AOP aopify, Action beforeAction)
 {
     aopify.BeforeAction = beforeAction;
     return(aopify);
 }
Example #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)));
 }
Example #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)));
 }
Example #16
0
 public static AOP ProcessAsync(this AOP aspect)
 {
     return(aspect.Combine(process => process.BeginInvoke(process.EndInvoke, null)));
 }