Example #1
0
        public static IType AddRandomType(this ITypeCategory category, Authentication authentication)
        {
            var template = category.NewType(authentication);

            template.InitializeRandom(authentication);
            template.EndEdit(authentication);
            return(template.Type);
        }
Example #2
0
 public void NewType(ITypeCategory category, TaskContext context)
 {
     category.Dispatcher.Invoke(() =>
     {
         var template = category.NewType(context.Authentication);
         context.Push(template);
     });
 }
Example #3
0
        //public static void GenerateStandardTable(this ITableCategory category, Authentication authentication)
        //{
        //    var types1 = category.DataBase.TypeContext.Types.Select(item => item.Name).ToArray();
        //    var types2 = CremaTypeUtility.GetBaseTypes();
        //    var allTypes = types1.Concat(types2);

        //    foreach (var item in allTypes)
        //    {
        //        var tableName = string.Join("_", "SingleKey", item);
        //        var template = category.NewTable(authentication);
        //        template.SetTableName(authentication, tableName);
        //        template.SetComment(authentication, string.Format("Single Key Table : {0}", item));

        //        template.AddKey(authentication, item, item);

        //        var extraTypes = allTypes.Where(i => i != item);

        //        foreach (var i in extraTypes)
        //        {
        //            template.AddColumn(authentication, i, i);
        //        }

        //        template.EndEdit(authentication);
        //    }
        //}

        public static void GenerateStandardType(this ITypeCategory category, Authentication authentication)
        {
            var template = category.NewType(authentication);

            template.SetIsFlag(authentication, false);
            template.SetComment(authentication, "Standard Type");

            var az = Enumerable.Range('A', 'Z' - 'A' + 1).Select(i => (char)i).ToArray();

            template.AddMember(authentication, "None", 0, "None Value");
            for (int i = 0; i < az.Length; i++)
            {
                template.AddMember(authentication, az[i].ToString(), (long)i + 1, az[i] + " Value");
            }

            template.EndEdit(authentication);
        }
Example #4
0
        public static void GenerateStandardFlags(this ITypeCategory category, Authentication authentication)
        {
            var newName  = NameUtility.GenerateNewName("Flag", category.DataBase.TypeContext.Types.Select(item => item.Name).ToArray());
            var template = category.NewType(authentication);

            template.SetTypeName(authentication, newName);
            template.SetIsFlag(authentication, true);
            template.SetComment(authentication, "Standard Flag");

            template.AddMember(authentication, "None", 0, "None Value");
            template.AddMember(authentication, "A", 1, "A Value");
            template.AddMember(authentication, "B", 2, "B Value");
            template.AddMember(authentication, "C", 4, "C Value");
            template.AddMember(authentication, "D", 8, "D Value");
            template.AddMember(authentication, "AC", 1 | 4, "AC Value");
            template.AddMember(authentication, "ABC", 1 | 2 | 4, "AC Value");
            template.AddMember(authentication, "BD", 2 | 8, "AC Value");
            template.AddMember(authentication, "All", 1 | 2 | 4 | 8, "All Value");

            template.EndEdit(authentication);
        }
Example #5
0
        public static Task <NewTypeViewModel> CreateInstanceAsync(Authentication authentication, ITypeCategoryDescriptor descriptor)
        {
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }
            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (descriptor.Target is ITypeCategory category)
            {
                return(category.Dispatcher.InvokeAsync(() =>
                {
                    var template = category.NewType(authentication);
                    return new NewTypeViewModel(authentication, category, template);
                }));
            }
            else
            {
                throw new ArgumentException("Invalid Target of Descriptor", nameof(descriptor));
            }
        }
Example #6
0
 public void NewType()
 {
     category.NewType(authentication);
 }