private Control AddPropertySelectorInputControl(IUserOption option) { ComboBox box = new ComboBox(); box.DropDownStyle = ComboBoxStyle.DropDownList; Entity entity = IsEnd1 ? Reference.Entity2 : Reference.Entity1; box.Items.Add(new ComboBoxItemEx <object>(null, p => GetPropertyName(null, ""))); foreach (Property prop in entity.Properties) { box.Items.Add(new ComboBoxItemEx <object>(prop, p => GetPropertyName(p, ""))); if (!(option.Value is string)) { if (!(option.Value is ArchAngel.Interfaces.NHibernateEnums.PropertiesForThisEntity)) { ArchAngel.Providers.EntityModel.Model.EntityLayer.Property optionProp = (ArchAngel.Providers.EntityModel.Model.EntityLayer.Property)option.Value; if (option.Value != null && optionProp.Name.Equals(prop.Name, StringComparison.InvariantCultureIgnoreCase)) { box.SelectedIndex = box.Items.Count - 1; } } } } box.SelectedIndexChanged += (sender, e) => OnVirtualPropertyValueChanged(sender as Control); return(box); }
private SlyceTreeGridCellItem CreateNewNullableCell(ArchAngel.Providers.EntityModel.Model.EntityLayer.Property property, object value, ApplicableOptions options) { ApplicableOptions applicableOptions = ValidationOptions.GetApplicableValidationOptionsForType(property.Type); SlyceTreeGridCellItem cell = new SlyceTreeGridCellItem(value, (applicableOptions & options) != options); cell.IsNullable = true; return(cell); }
private static void SetPropertyInfoFromParsedCode(List<Class> possibleClasses, Property property) { foreach (var possibleClass in possibleClasses) { var possibleProperty = possibleClass.Properties.FirstOrDefault(p => p.Name == property.Name); if (possibleProperty != null) { // We have successfully found the property. Get the information we need from it. property.Type = possibleProperty.DataType.ToString(); } } }
private static void SetPropertyInfoFromParsedCode(Property property, ParseResults results, string @namespace, string tableSchema, string className) { if (string.IsNullOrEmpty(className)) return; List<Class> possibleClasses = GetPossibleClasses(className, @namespace, tableSchema, results); if (possibleClasses.Count == 0) return; // Attempt to find property SetPropertyInfoFromParsedCode(possibleClasses, property); }
private static bool IsStringType(Property property) { return (property.Type == "string" || property.Type == "System.String" || property.Type == "String"); }
private void AddPropertyToPropertiesGrid(ArchAngel.Providers.EntityModel.Model.EntityLayer.Property property, bool hasMultiSchemas) { SlyceTreeGridItem gridItem = new SlyceTreeGridItem(); gridItem.Tag = property; gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.Name)); gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.Type)); gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.NHibernateType)); int numTables = MappedTables.Count; IColumn mappedColumn = property.MappedColumn(); string mappedColumnName; if (mappedColumn == null) { mappedColumnName = ""; } else if (numTables == 1) { mappedColumnName = mappedColumn.Name; } else if (hasMultiSchemas) { mappedColumnName = string.Format("{0}.{1}.{2}", mappedColumn.Parent.Schema, mappedColumn.Parent.Name, mappedColumn.Name); } else { mappedColumnName = string.Format("{0}.{1}", mappedColumn.Parent.Name, mappedColumn.Name); } gridItem.SubItems.Add(new SlyceTreeGridCellItem(mappedColumnName)); gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.IsKeyProperty)); gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.ReadOnly)); foreach (ArchAngel.Interfaces.ITemplate.IUserOption uo in property.Ex.OrderBy(u => u.Name)) { if (uo.DataType == typeof(bool?)) { bool?nullableBoolValue = (bool?)uo.Value; gridItem.SubItems.Add(new SlyceTreeGridCellItem(false, true, nullableBoolValue.HasValue ? nullableBoolValue.Value : false)); } else if (uo.DataType == typeof(string)) { gridItem.SubItems.Add(new SlyceTreeGridCellItem((string)uo.Value)); } else if (uo.DataType == typeof(int)) { gridItem.SubItems.Add(new SlyceTreeGridCellItem((int)uo.Value)); } else if (uo.DataType == typeof(bool)) { gridItem.SubItems.Add(new SlyceTreeGridCellItem((bool)uo.Value)); } else if (uo.DataType.ToString() == "ArchAngel.Interfaces.NHibernateEnums.PropertyAccessTypes") { gridItem.SubItems.Add(new SlyceTreeGridCellItem(uo.Value.ToString())); } else if (uo.DataType.ToString() == "ArchAngel.Interfaces.NHibernateEnums.PropertyGeneratedTypes") { gridItem.SubItems.Add(new SlyceTreeGridCellItem(uo.Value.ToString())); } else { throw new NotImplementedException("Type not handled yet: " + uo.DataType.Name); } } gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.FractionalDigits, ApplicableOptions.Digits)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.FutureDate, ApplicableOptions.Date)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.IntegerDigits, ApplicableOptions.Digits)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MaximumLength, ApplicableOptions.Length)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MinimumLength, ApplicableOptions.Length)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MaximumValue, ApplicableOptions.Value)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MinimumValue, ApplicableOptions.Value)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.NotEmpty, ApplicableOptions.NotEmpty)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.Nullable, ApplicableOptions.Nullable)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.PastDate, ApplicableOptions.Date)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.RegexPattern, ApplicableOptions.RegexPattern)); gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.ValidationOptions.Validate, (ValidationOptions.GetApplicableValidationOptionsForType(property.Type) & ApplicableOptions.Validate) != ApplicableOptions.Validate)); slyceGrid1.Items.Add(gridItem); }