예제 #1
0
 public void NewTable(ITableCategory category, TaskContext context)
 {
     category.Dispatcher.Invoke(() =>
     {
         var template = category.NewTable(context.Authentication);
         context.Push(template);
     });
 }
예제 #2
0
        public static ITable AddRandomTable(this ITableCategory category, Authentication authentication)
        {
            var template = category.NewTable(authentication);

            template.InitializeRandom(authentication);
            template.EndEdit(authentication);
            var table = template.Table;

            AddRandomRows(table, authentication, RandomUtility.Next(MinRowCount, MaxRowCount));
            return(table);
        }
예제 #3
0
        public static ITable GenerateStandardTable(this ITableCategory category, Authentication authentication, string prefix, IEnumerable <string> keyTypes, IEnumerable <string> columnTypes)
        {
            var tables    = category.GetService <ITableCollection>();
            var tableName = string.Join("_", EnumerableUtility.Friends(prefix, keyTypes));

            if (tables.Contains(tableName) == true)
            {
                return(null);
            }

            var template = category.NewTable(authentication);

            template.SetTableName(authentication, tableName);

            foreach (var item in keyTypes)
            {
                template.AddKey(authentication, item, item);
            }

            foreach (var item in columnTypes)
            {
                template.AddColumn(authentication, item, item);
            }

            try
            {
                template.EndEdit(authentication);
                return(template.Table);
            }
            catch
            {
                template.CancelEdit(authentication);
                return(null);
            }

            //var table = template.Table;
            //var content = table.Content;

            //content.BeginEdit(authentication);
            //content.EnterEdit(authentication);
            //try
            //{
            //    content.GenerateRows(authentication, RandomUtility.Next(10, 1000));
            //    content.LeaveEdit(authentication);
            //    content.EndEdit(authentication);
            //}
            //catch
            //{
            //    content.CancelEdit(authentication);
            //}

            //return table;
        }
 public static void NewTableFailTest <T>(ICremaHost cremaHost, ITableCategory category, Authentication authentication) where T : Exception
 {
     cremaHost.Dispatcher.Invoke(() =>
     {
         try
         {
             category.NewTable(authentication);
             Assert.Fail("NewTable");
         }
         catch (T)
         {
         }
     });
 }
예제 #5
0
        private static void CreateTable(Authentication authentication, ITableCategory category, string name, TagInfo tags)
        {
            var template = category.NewTable(authentication);

            template.SetTableName(authentication, name);
            template.SetTags(authentication, tags);
            template.SetComment(authentication, $"table-{tags}");

            var key = template.AddNew(authentication);

            key.SetName(authentication, "key_column");
            key.SetIsKey(authentication, true);
            template.EndNew(authentication, key);

            var all = template.AddNew(authentication);

            all.SetName(authentication, "all_column");
            template.EndNew(authentication, all);

            var server = template.AddNew(authentication);

            server.SetName(authentication, "server_column");
            template.EndNew(authentication, server);

            var client = template.AddNew(authentication);

            client.SetName(authentication, "client_column");
            template.EndNew(authentication, client);

            var none = template.AddNew(authentication);

            none.SetName(authentication, "none_column");
            template.EndNew(authentication, none);

            template.EndEdit(authentication);

            var table = template.Table;

            CreateTable(authentication, table, "child_all", TagInfoUtility.All);
            CreateTable(authentication, table, "child_server", TagInfoUtility.Server);
            CreateTable(authentication, table, "child_client", TagInfoUtility.Client);
            CreateTable(authentication, table, "child_none", TagInfoUtility.Unused);
        }
예제 #6
0
        public static Task <NewTableViewModel> CreateInstanceAsync(Authentication authentication, ITableCategoryDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is ITableCategory category)
            {
                return(category.Dispatcher.InvokeAsync(() =>
                {
                    var template = category.NewTable(authentication);
                    return new NewTableViewModel(authentication, category, template);
                }));
            }
            else
            {
                throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor));
            }
        }
 public void NewTable()
 {
     category.NewTable(authentication);
 }