public static Schema BuildMultiChoice(Type enumType, params int[] defaultValues) { var choiceSet = ChoiceSet.FromEnum(enumType); choiceSet.Defaults = defaultValues.ToList(); return(new SchemaBuilder(enumType.FullName, DataType.MultiChoice, choiceSet.ToEditable(new EditableFactory(null))).ToSchema()); }
public static Schema BuildChoice(Type enumType, int?defaultValue) { var choiceSet = ChoiceSet.FromEnum(enumType); if (defaultValue.HasValue) { choiceSet.Defaults = new List <int> { defaultValue.Value } } ; return(new SchemaBuilder(enumType.FullName, DataType.Choice, choiceSet.ToEditable(new EditableFactory(null))).ToSchema()); }
Schema BuildSchemaForEnum(Type type, string schemaName, List <Tuple <Type, Schema> > schemaList) { var dataType = DataType.Choice; var choiceSetAttribute = type.GetTypeInfo().GetCustomAttribute <ChoiceSetAttribute>(); if (choiceSetAttribute != null && choiceSetAttribute.MultiChoice) { dataType = DataType.MultiChoice; } var sb = new SchemaBuilder(schemaName, dataType, ChoiceSet.FromEnum(type).ToEditable(editableFactory)); var result = sb.ToSchema(); if (choiceSetAttribute != null) { result.Id = choiceSetAttribute.SchemaId; } schemaList.Add(Tuple.Create(type, result)); return(result); }