Exemple #1
0
 public static AspectF RunAsync(this AspectF aspect)
 {
     return(aspect.Combine((work) => work.BeginInvoke(asyncresult =>
     {
         work.EndInvoke(asyncresult);
     }, null)));
 }
Exemple #2
0
 public static AspectF Delay(this AspectF aspect, int milliseconds)
 {
     return(aspect.Combine((work) =>
     {
         System.Threading.Thread.Sleep(milliseconds);
         work();
     }));
 }
Exemple #3
0
 public static AspectF RunAsync(this AspectF aspect, Action completeCallback)
 {
     return(aspect.Combine((work) => work.BeginInvoke(asyncresult =>
     {
         work.EndInvoke(asyncresult);
         completeCallback();
     }, null)));
 }
Exemple #4
0
 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();
     }));
 }
Exemple #5
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();
     }));
 }
Exemple #6
0
 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();
     }));
 }