public static Task <IType[]> GetRandomTypesAsync(this ITypeCollection typeCollection, TypeFlags typeFlags, Func <IType, bool> predicate)
 {
     return(typeCollection.Dispatcher.InvokeAsync(() =>
     {
         var query = from item in typeCollection
                     where TypeFlagsUtility.Test(item, typeFlags) == true && predicate(item) == true
                     let i = RandomUtility.Next <int>()
                             orderby i
                             select item;
         return query.ToArray();
     }));
 }
Example #2
0
 private bool PredicateFunc(IType type)
 {
     if (this.TypeFlags != TypeFlags.None && TypeFlagsUtility.Test(type, this.TypeFlags) == false)
     {
         return(false);
     }
     if (this.ExcludedTypeNames != null && this.ExcludedTypeNames.Contains(type.Name) == true)
     {
         return(false);
     }
     if (this.Predicate != null && this.Predicate(type) == false)
     {
         return(false);
     }
     return(true);
 }
 public static Task <IType> GetRandomTypeAsync(this ITypeCollection typeCollection, TypeFlags typeFlags, Func <IType, bool> predicate)
 {
     return(typeCollection.Dispatcher.InvokeAsync(() => typeCollection.RandomOrDefault(item => TypeFlagsUtility.Test(item, typeFlags) == true && predicate(item) == true)));
 }