public TestModel() : base("test.test_model") { IsVersioned = false; Fields.Chars("name").SetLabel("姓名").SetSize(64).Required(); Fields.Chars("address").SetLabel("地址").SetSize(200).Required(); Fields.Integer("field1").SetLabel("数1"); Fields.Integer("field2").SetLabel("数2"); Fields.Integer("field3").SetLabel("数3").SetValueGetter(this.GetField3); Fields.BigInteger("big_int_field").SetLabel("Bit Int Field"); Fields.Boolean("boolean_field").SetLabel("Boolean Field").Required().SetDefaultValueGetter(s => true); Fields.Text("text_field").SetLabel("Text Field"); Fields.Double("double_field").SetLabel("Double Field"); Fields.Decimal("money_field").SetLabel("Decimal Field"); Fields.Enumeration("enum_field", new Dictionary <string, string>() { { "state1", "State 1" }, { "state2", "State2" } }) .SetLabel("Enumeration Field"); Fields.Binary("binary_field").SetLabel("Binary Field"); Fields.Reference("reference_field").SetLabel("Reference Field").SetOptions( new Dictionary <string, string>() { { "test.master", "Master Model" }, { "test.child", "Child Model" }, }); }
public void Should_get_default_value_from_boolean_field() { var field = Fields.Boolean(1, "1", Partitioning.Invariant, new BooleanFieldProperties { DefaultValue = true }); Assert.Equal(true, DefaultValueFactory.CreateDefaultValue(field, Now)); }
public void Should_format_boolean_field_with_false() { var value = JsonValue.False; var field = Fields.Boolean(1, "field", Partitioning.Invariant); var formatted = StringFormatter.Format(field, value); Assert.Equal("No", formatted); }
public void Should_format_boolean_field_with_wrong_type() { var value = JsonValue.Zero; var field = Fields.Boolean(1, "field", Partitioning.Invariant); var formatted = StringFormatter.Format(value, field); Assert.Equal("No", formatted); }
public AuditLogModel() : base(ModelName) { Fields.ManyToOne("user", "core.user").SetLabel("User"); Fields.Boolean("marked").SetLabel("Marked As Read") .Required().SetDefaultValueGetter(ctx => false); Fields.Chars("resource").SetLabel("Resource Name").SetSize(64).Required(); Fields.BigInteger("resource_id").SetLabel("Resource ID").Required(); Fields.Chars("description").SetLabel("Description") .Required().SetSize(256); }
public FieldAccessEntity() : base(EntityName) { Fields.Chars("name").WithLabel("Name"); Fields.ManyToOne("role", "core.role") .OnDelete(OnDeleteAction.Cascade).WithLabel("Role"); Fields.ManyToOne("field", "core.meta_field").WithRequired() .OnDelete(OnDeleteAction.Cascade).WithLabel("Field"); Fields.Boolean("allow_read").WithLabel("Allow Reading") .WithRequired().WithDefaultValueGetter(s => true); Fields.Boolean("allow_write").WithLabel("Allow Writing") .WithRequired().WithDefaultValueGetter(s => true); }
public FieldAccessModel() : base(ModelName) { Fields.Chars("name").SetLabel("Name"); Fields.ManyToOne("role", "core.role") .OnDelete(OnDeleteAction.Cascade).SetLabel("Role"); Fields.ManyToOne("field", "core.field").Required() .OnDelete(OnDeleteAction.Cascade).SetLabel("Field"); Fields.Boolean("allow_read").SetLabel("Allow Reading") .Required().SetDefaultValueGetter(s => true); Fields.Boolean("allow_write").SetLabel("Allow Writing") .Required().SetDefaultValueGetter(s => true); }
public UserEntity() : base("core.user") { Fields.Chars("login").WithLabel("User Name").WithSize(64).WithRequired().WithUnique(); Fields.Chars("password").WithLabel("Password").WithSize(64).WithRequired(); Fields.Chars("salt").WithLabel("Salt").WithSize(64).WithRequired(); Fields.Boolean("admin").WithLabel("Administrator?").WithRequired().WithDefaultValueGetter(r => false); Fields.Chars("name").WithLabel("Name").WithRequired().WithSize(64); Fields.ManyToMany("roles", "core.user_role", "user", "role").WithLabel("Roles"); Fields.ManyToOne("organization", "core.organization").WithLabel("Organization").WithNotRequired(); Fields.ManyToOne("home_action", "core.action").WithLabel("Home Action").WithNotRequired(); Fields.Chars("email").WithLabel("Email").WithNotRequired().WithSize(256); Fields.Boolean("active").WithLabel("Active?").WithRequired().WithDefaultValueGetter(r => true); }
public TestBatModel() : base("test.bat") { IsVersioned = false; Inherit("test.animal", "animal"); Inherit("test.flyable", "flyable"); Fields.ManyToOne("animal", "test.animal").Required() .OnDelete(OnDeleteAction.Cascade).SetLabel("Base Animal Model"); Fields.ManyToOne("flyable", "test.flyable").Required() .OnDelete(OnDeleteAction.Cascade).SetLabel("Base Flyable Model"); Fields.Boolean("sucker").SetLabel("Is Sucker?"); }
public MetaFieldEntity() : base(EntityName) { this.IsVersioned = false; Fields.ManyToOne("meta_entity", MetaEntityEntity.EntityName).WithLabel("Meta Entity") .WithRequired().OnDelete(OnDeleteAction.Cascade); Fields.Chars("name").WithLabel("Name").WithSize(64).WithRequired(); Fields.Chars("label").WithLabel("Label").WithSize(256).WithNotRequired(); Fields.Boolean("required").WithLabel("Required").WithRequired(); Fields.Boolean("readonly").WithLabel("Read Only").WithRequired(); Fields.Chars("relation").WithLabel("Relation").WithSize(256).WithNotRequired(); Fields.Chars("type").WithLabel("Type").WithSize(32).WithRequired(); Fields.Chars("help").WithLabel("Help").WithSize(256).WithNotRequired(); }
public ModelAccessModel() : base(ModelName) { Fields.ManyToOne("role", "core.role").Required().SetLabel("Role"); Fields.ManyToOne("model", "core.model").Required().SetLabel("Model"); Fields.Chars("name").SetLabel("Name"); Fields.Boolean("allow_create").SetLabel("Allow Creation") .Required().SetDefaultValueGetter(s => true); Fields.Boolean("allow_read").SetLabel("Allow Reading") .Required().SetDefaultValueGetter(s => true); Fields.Boolean("allow_write").SetLabel("Allow Writing") .Required().SetDefaultValueGetter(s => true); Fields.Boolean("allow_delete").SetLabel("Allrow Deletion") .Required().SetDefaultValueGetter(s => true); }
public EntityAccessEntity() : base(EntityName) { Fields.ManyToOne("role", "core.role").WithRequired().WithLabel("Role"); Fields.ManyToOne("meta_entity", "core.meta_entity").WithRequired().WithLabel("Meta Entity"); Fields.Chars("name").WithLabel("Name"); Fields.Boolean("allow_create").WithLabel("Allow Creation") .WithRequired().WithDefaultValueGetter(s => true); Fields.Boolean("allow_read").WithLabel("Allow Reading") .WithRequired().WithDefaultValueGetter(s => true); Fields.Boolean("allow_write").WithLabel("Allow Writing") .WithRequired().WithDefaultValueGetter(s => true); Fields.Boolean("allow_delete").WithLabel("Allrow Deletion") .WithRequired().WithDefaultValueGetter(s => true); }
public FieldModel() : base(ModelName) { this.IsVersioned = false; Fields.ManyToOne("model", "core.model").SetLabel("Model") .Required().OnDelete(OnDeleteAction.Cascade); Fields.Chars("name").SetLabel("Name").SetSize(64).Required(); Fields.Chars("label").SetLabel("Label").SetSize(256).NotRequired(); Fields.Boolean("required").SetLabel("Required").Required(); Fields.Boolean("readonly").SetLabel("Read Only").Required(); Fields.Chars("relation").SetLabel("Relation").SetSize(256).NotRequired(); Fields.Chars("type").SetLabel("Type").SetSize(32).Required(); Fields.Chars("help").SetLabel("Help").SetSize(256).NotRequired(); }
public RuleEntity() : base("core.rule") { Fields.Chars("name").WithLabel("Name").WithRequired(); Fields.ManyToOne("meta_entity", "core.meta_entity").WithRequired().WithLabel("Meta Entity"); Fields.Boolean("global").WithLabel("Global") .WithRequired().WithDefaultValueGetter(s => true); Fields.Boolean("on_create").WithLabel("Apply for Creation") .WithRequired().WithDefaultValueGetter(s => true); Fields.Boolean("on_read").WithLabel("Apply for Reading") .WithRequired().WithDefaultValueGetter(s => true); Fields.Boolean("on_write").WithLabel("Apply for Writing") .WithRequired().WithDefaultValueGetter(s => true); Fields.Boolean("on_delete").WithLabel("Apply for Deleting") .WithRequired().WithDefaultValueGetter(s => true); Fields.ManyToMany("roles", "core.rule_role", "rule", "role").WithLabel("Roles"); Fields.Chars("constraint").WithRequired().WithLabel("Constraint"); }
public MenuModel() : base("core.menu") { this.Hierarchy = true; Fields.Chars("name").SetLabel("Name").Required(); Fields.Integer("ordinal").SetLabel("Ordinal Number") .Required().SetDefaultValueGetter(arg => 0); Fields.ManyToOne("parent", "core.menu").SetLabel("Parent Menu").NotRequired(); Fields.Chars("icon").SetLabel("Icon Name").NotRequired(); Fields.Boolean("active").SetLabel("Active").Required().SetDefaultValueGetter(arg => true); Fields.Reference("action").SetLabel("Action").NotRequired().SetOptions( new Dictionary <string, string>() { { "core.action_window", "Window Action" }, { "core.action_wizard", "Wizard Action" }, }); }
/// <summary> /// 单个数据库中加载的模块 /// </summary> public ModuleEntity() : base(EntityName) { this.IsVersioned = false; Fields.Chars("name").WithLabel("Name").WithRequired().WithSize(128).WithUnique().WithReadonly(); Fields.Chars("label").WithLabel("Short Description").WithSize(256).WithReadonly(); Fields.Enumeration("state", new Dictionary <string, string>() { { States.Uninstalled, "Uninstalled" }, { States.Installed, "Installed" }, { States.ToInstall, "To Install" }, { States.ToUpgrade, "To Upgrade" }, { States.ToUninstall, "To Uninstall" }, }).WithRequired().WithLabel("State").WithReadonly(); Fields.Boolean("demo").WithLabel("Demostration?").WithRequired().WithReadonly().WithDefaultValueGetter(getter => false); Fields.Chars("author").WithLabel("Author").WithSize(128).WithReadonly(); Fields.Chars("url").WithLabel("Web Site").WithSize(128).WithReadonly(); Fields.Chars("version").WithLabel("Version").WithSize(64).WithReadonly(); Fields.Chars("license").WithLabel("License").WithSize(32).WithReadonly(); Fields.OneToMany("depends", "core.module_dependency", "module") .WithLabel("Dependencies"); Fields.Text("info").WithLabel("Information").WithReadonly(); }
public TestEntity() : base("test.test_entity") { IsVersioned = false; Fields.Chars("name").WithLabel("姓名").WithSize(64).WithRequired(); Fields.Chars("address").WithLabel("地址").WithSize(200).WithRequired(); Fields.Integer("field1").WithLabel("数1"); Fields.Integer("field2").WithLabel("数2"); Fields.Integer("field3").WithLabel("数3").WithValueGetter(this.GetField3); Fields.BigInteger("big_int_field").WithLabel("Bit Int Field"); Fields.Boolean("boolean_field").WithLabel("Boolean Field").WithRequired().WithDefaultValueGetter(s => true); Fields.Text("text_field").WithLabel("Text Field"); Fields.Xml("xml_field").WithLabel("XML Field"); Fields.Double("double_field").WithLabel("Double Field"); Fields.Decimal("money_field").WithLabel("Decimal Field"); Fields.Date("date_field").WithLabel("Date Field"); Fields.Time("time_field").WithLabel("Time Field"); Fields.DateTime("datetime_field").WithLabel("DateTime Field"); Fields.Enumeration("enum_field", new Dictionary <string, string>() { { "state1", "State 1" }, { "state2", "State2" } }) .WithLabel("Enumeration Field"); Fields.Binary("binary_field").WithLabel("Binary Field"); Fields.Reference("reference_field").WithLabel("Reference Field").WithOptions( new Dictionary <string, string>() { { "test.master", "Master Entity" }, { "test.child", "Child Entity" }, }); }
public override NestedField CreateNestedField(long id, string name, IFieldSettings?settings = null) { return(Fields.Boolean(id, name, this, settings)); }
public override RootField CreateRootField(long id, string name, Partitioning partitioning, IFieldSettings?settings = null) { return(Fields.Boolean(id, name, partitioning, this, settings)); }
private static RootField <BooleanFieldProperties> Field(BooleanFieldProperties properties) { return(Fields.Boolean(1, "my-boolean", Partitioning.Invariant, properties)); }