コード例 #1
0
 public static AspectF RunAsync(this AspectF aspect, Action completeCallback)
 {
     return(aspect.Combine(work => work.BeginInvoke(asyncresult =>
     {
         work.EndInvoke(asyncresult); completeCallback();
     }, null)));
 }
コード例 #2
0
 public static AspectF Delay(this AspectF aspect, int milliseconds)
 {
     return(aspect.Combine(work =>
     {
         System.Threading.Thread.Sleep(milliseconds);
         work();
     }));
 }
コード例 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aspect"></param>
 /// <param name="conditions"></param>
 /// <returns></returns>
 public static AspectF WhenTrue(this AspectF aspect, params Func <bool>[] conditions)
 {
     return(aspect.Combine(work =>
     {
         foreach (Func <bool> condition in conditions)
         {
             if (!condition())
             {
                 return;
             }
         }
         work();
     }));
 }
コード例 #4
0
 public static AspectF MustBeNonNull(this AspectF aspect, params object[] args)
 {
     return(aspect.Combine(work =>
     {
         for (int i = 0; i < args.Length; i++)
         {
             object arg = args[i];
             if (arg == null)
             {
                 throw new ArgumentException(string.Format("Parameter at index {0} is null", i));
             }
         }
         work();
     }));
 }
コード例 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aspect"></param>
 /// <param name="args"></param>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 /// <exception cref="ArgumentException"></exception>
 public static AspectF MustBeNonDefault <T>(this AspectF aspect, params T[] args) where T : IComparable
 {
     return(aspect.Combine(work =>
     {
         T defaultvalue = default(T);
         for (int i = 0; i < args.Length; i++)
         {
             T arg = args[i];
             if (arg == null || arg.Equals(defaultvalue))
             {
                 throw new ArgumentException(string.Format("Parameter at index {0} is null", i));
             }
         }
         work();
     }));
 }
コード例 #6
0
 public static AspectF RunAsync(this AspectF aspect)
 {
     return(aspect.Combine(work => work.BeginInvoke(work.EndInvoke, null)));
 }