示例#1
0
文件: AspectF.cs 项目: zero1036/TGNet
 public static AspectF RunAsync(this AspectF aspect)
 {
     return(aspect.Combine((work) => work.BeginInvoke(asyncresult =>
     {
         work.EndInvoke(asyncresult);
     }, null)));
 }
示例#2
0
文件: AspectF.cs 项目: zero1036/TGNet
 public static AspectF RunAsync(this AspectF aspect, Action completeCallback)
 {
     return(aspect.Combine((work) => work.BeginInvoke(asyncresult =>
     {
         work.EndInvoke(asyncresult); completeCallback();
     }, null)));
 }
示例#3
0
文件: AspectF.cs 项目: zero1036/TGNet
 public static AspectF Delay(this AspectF aspect, int milliseconds)
 {
     return(aspect.Combine((work) =>
     {
         System.Threading.Thread.Sleep(milliseconds);
         work();
     }));
 }
示例#4
0
文件: AspectF.cs 项目: zero1036/TGNet
 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();
     }));
 }
示例#5
0
文件: AspectF.cs 项目: zero1036/TGNet
 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();
     }));
 }
示例#6
0
文件: AspectF.cs 项目: zero1036/TGNet
 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();
     }));
 }