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