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

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

                itemList.Add(item);
            }
            return(itemList.ToArray());
        }
Пример #2
0
 private CopyTableViewModel(Authentication authentication, ITable table, bool useTemplate)
 {
     this.authentication = authentication;
     this.table          = table;
     this.table.Dispatcher.VerifyAccess();
     this.useTemplate   = useTemplate;
     this.tables        = table.GetService(typeof(ITableCollection)) as ITableCollection;
     this.categories    = table.GetService(typeof(ITableCategoryCollection)) as ITableCategoryCollection;
     this.categoryPath  = this.table.Category.Path;
     this.categoryPaths = this.categories.Select(item => item.Path).OrderBy(item => item).ToArray();
     this.tableName     = table.Name;
     this.newName       = table.Name;
     this.DisplayName   = Resources.Title_CopyTable;
 }
 public static void ClassInit(TestContext context)
 {
     app = new CremaBootstrapper();
     app.Initialize(context, nameof(ITableCategoryCollection_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.Initialize(authentication);
         categories = dataBase.TableContext.Categories;
     });
 }
Пример #4
0
 public static ITableCategory RandomSample(this ITableCategoryCollection 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.Tables.Any(i => i.TemplatedParent == null && i.Childs.Any()) == false)
         {
             return false;
         }
         return true;
     }));
 }
Пример #5
0
 public static Task <ITableCategory[]> GetCategoriesAsync(this ITableCategoryCollection tableCategoryCollection)
 {
     return(tableCategoryCollection.Dispatcher.InvokeAsync(() => tableCategoryCollection.ToArray()));
 }
Пример #6
0
 public static Task <ITableCategory> GetCategoryAsync(this ITableCategoryCollection tableCategoryCollection, string categoryPath)
 {
     return(tableCategoryCollection.Dispatcher.InvokeAsync(() => tableCategoryCollection[categoryPath]));
 }
Пример #7
0
 public static Task <int> GetCountAsync(this ITableCategoryCollection tableCategoryCollection)
 {
     return(tableCategoryCollection.Dispatcher.InvokeAsync(() => tableCategoryCollection.Count));
 }
Пример #8
0
 public static Task <bool> ContainsAsync(this ITableCategoryCollection tableCategoryCollection, string categoryPath)
 {
     return(tableCategoryCollection.Dispatcher.InvokeAsync(() => tableCategoryCollection.Contains(categoryPath)));
 }
        public static async Task <ITableCategory> GenerateCategoryAsync(this ITableCategoryCollection tableCategoryCollection, Authentication authentication)
        {
            var category = RandomUtility.Within(50) == true ? tableCategoryCollection.Root : await tableCategoryCollection.GetRandomTableCategoryAsync();

            return(await category.AddNewCategoryAsync(authentication, RandomUtility.NextIdentifier()));
        }
 public static Task <ITableCategory> GetRandomTableCategoryAsync(this ITableCategoryCollection tableCategoryCollection, Func <ITableCategory, bool> predicate)
 {
     return(tableCategoryCollection.Dispatcher.InvokeAsync(() => tableCategoryCollection.Random(predicate)));
 }
 public static Task <ITableCategory> GetRandomTableCategoryAsync(this ITableCategoryCollection tableCategoryCollection)
 {
     return(GetRandomTableCategoryAsync(tableCategoryCollection, DefaultPredicate));
 }