public static async Task <ITypeCategory[]> GenerateCategoriesAsync(this ITypeCategoryCollection typeCategoryCollection, Authentication authentication, int count)
        {
            var itemList = new List <ITypeCategory>(count);

            for (var i = 0; i < count; i++)
            {
                var item = await typeCategoryCollection.GenerateCategoryAsync(authentication);

                itemList.Add(item);
            }
            return(itemList.ToArray());
        }
Exemple #2
0
 private CopyTypeViewModel(Authentication authentication, IType type)
 {
     this.authentication = authentication;
     this.type           = type;
     this.type.Dispatcher.VerifyAccess();
     this.types         = type.GetService(typeof(ITypeCollection)) as ITypeCollection;
     this.categories    = type.GetService(typeof(ITypeCategoryCollection)) as ITypeCategoryCollection;
     this.categoryPaths = this.categories.Select(item => item.Path).ToArray();
     this.categoryPath  = this.type.Category.Path;
     this.typeName      = type.Name;
     this.NewName       = type.Name;
     this.DisplayName   = Resources.Title_CopyType;
 }
Exemple #3
0
 public static void ClassInit(TestContext context)
 {
     app = new CremaBootstrapper();
     app.Initialize(context, nameof(ITypeCategoryCollection_DispatcherTest));
     cremaHost = app.GetService(typeof(ICremaHost)) as ICremaHost;
     cremaHost.Dispatcher.Invoke(() =>
     {
         authentication = cremaHost.Start();
         dataBase       = cremaHost.DataBases.Random();
         dataBase.Load(authentication);
         dataBase.Enter(authentication);
         dataBase.TypeContext.AddRandomItems(authentication);
         categories = dataBase.TypeContext.Categories;
     });
 }
Exemple #4
0
 public static ITypeCategory RandomSample(this ITypeCategoryCollection categories)
 {
     return(categories.Random(item =>
     {
         if (item.Parent == null)
         {
             return false;
         }
         if (item.IsPrivate == true)
         {
             return false;
         }
         if (item.IsLocked == true)
         {
             return false;
         }
         if (item.Types.Any() == false)
         {
             return false;
         }
         return true;
     }));
 }
        public static async Task <ITypeCategory> GenerateCategoryAsync(this ITypeCategoryCollection typeCategoryCollection, Authentication authentication)
        {
            var category = RandomUtility.Within(50) == true ? typeCategoryCollection.Root : await typeCategoryCollection.GetRandomTypeCategoryAsync();

            return(await category.AddNewCategoryAsync(authentication, RandomUtility.NextIdentifier()));
        }
 public static Task <ITypeCategory> GetRandomTypeCategoryAsync(this ITypeCategoryCollection typeCategoryCollection, Func <ITypeCategory, bool> predicate)
 {
     return(typeCategoryCollection.Dispatcher.InvokeAsync(() => typeCategoryCollection.Random(predicate)));
 }
 public static Task <ITypeCategory> GetRandomTypeCategoryAsync(this ITypeCategoryCollection typeCategoryCollection)
 {
     return(GetRandomTypeCategoryAsync(typeCategoryCollection, DefaultPredicate));
 }
Exemple #8
0
 public static Task <int> GetCountAsync(this ITypeCategoryCollection typeCategoryCollection)
 {
     return(typeCategoryCollection.Dispatcher.InvokeAsync(() => typeCategoryCollection.Count));
 }
Exemple #9
0
 public static Task <ITypeCategory[]> GetCategoriesAsync(this ITypeCategoryCollection typeCategoryCollection)
 {
     return(typeCategoryCollection.Dispatcher.InvokeAsync(() => typeCategoryCollection.ToArray()));
 }
Exemple #10
0
 public static Task <ITypeCategory> GetCategoryAsync(this ITypeCategoryCollection typeCategoryCollection, string categoryPath)
 {
     return(typeCategoryCollection.Dispatcher.InvokeAsync(() => typeCategoryCollection[categoryPath]));
 }
Exemple #11
0
 public static Task <bool> ContainsAsync(this ITypeCategoryCollection typeCategoryCollection, string categoryPath)
 {
     return(typeCategoryCollection.Dispatcher.InvokeAsync(() => typeCategoryCollection.Contains(categoryPath)));
 }