Пример #1
0
        private SlyceTreeGridCellItem CreateNewNullableCell(ComponentPropertyImpl property, object value, ApplicableOptions options)
        {
            ApplicableOptions     applicableOptions = ValidationOptions.GetApplicableValidationOptionsForType(property.Type);
            SlyceTreeGridCellItem cell = new SlyceTreeGridCellItem(value, (applicableOptions & options) != options);

            cell.IsNullable = true;
            return(cell);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public static string CreateXmlForEntity(Entity entity, string assembly, string @namespace)
        {
            using (var ms = new MemoryStream())
                using (var writer = XmlWriter.Create(ms, new XmlWriterSettings {
                    Indent = true, IndentChars = "\t", Encoding = Encoding.UTF8
                }))
                {
                    writer.WriteStartDocument();
                    writer.WriteStartElement("nhv-mapping", "urn:nhibernate-validator-1.0");
                    writer.WriteAttributeString("assembly", assembly);
                    writer.WriteAttributeString("namespace", @namespace);
                    writer.WriteStartElement("class", "urn:nhibernate-validator-1.0");
                    writer.WriteAttributeString("name", entity.Name);

                    foreach (var property in entity.Properties.Except(entity.ForeignKeyPropertiesToExclude).OrderBy(p => p.Name))
                    {
                        var constraintActions = new List <Action <XmlWriter, ValidationOptions> >();
                        var options           = property.ValidationOptions;
                        var optsToUse         = ValidationOptions.GetApplicableValidationOptionsForType(property.Type);
                        constraintActions.AddRange(GetObjectConstraints(options, optsToUse));
                        constraintActions.AddRange(GetStringConstraints(options, optsToUse));
                        constraintActions.AddRange(GetIntegerConstraints(options, optsToUse));
                        constraintActions.AddRange(GetDateConstraints(options, optsToUse));

                        // If no nodes were created, don't both creating a property node
                        if (constraintActions.Any() == false)
                        {
                            continue;
                        }

                        writer.WriteStartElement("property", "urn:nhibernate-validator-1.0");
                        writer.WriteAttributeString("name", property.Name);

                        foreach (var action in constraintActions)
                        {
                            action(writer, property.ValidationOptions);
                        }

                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                    writer.Flush();
                    writer.Close();
                    return(Encoding.UTF8.GetString(ms.ToArray()));
                }
        }
Пример #4
0
        public FormProperty()
        {
            InitializeComponent();

            buttonRemoveProperty.Click += (s, e) => RemoveProperty.RaiseEventEx(this);

            tbType.TextChanged += (s, e) =>
            {
                DatatypeChanged.RaiseEventEx(this);
                validationPropertyGrid1.SetAvailableOptions(
                    ValidationOptions.GetApplicableValidationOptionsForType(tbType.Text));
            };
            tbName.TextChanged             += (s, e) => PropertyNameChanged.RaiseEventEx(this);
            cbReadOnly.CheckedChanged      += (s, e) => ReadOnlyChanged.RaiseEventEx(this);
            cbIsKeyProperty.CheckedChanged += (s, e) => IsKeyChanged.RaiseEventEx(this);

            tbType.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            tbType.AutoCompleteSource = AutoCompleteSource.CustomSource;
            var collection = new AutoCompleteStringCollection();

            collection.AddRange(SQLServer.CLRTypeList.ToArray());
            tbType.AutoCompleteCustomSource = collection;
        }
Пример #5
0
        private void AddPropertyToPropertiesGrid(ComponentPropertyImpl property)
        {
            SlyceTreeGridItem gridItem = new SlyceTreeGridItem();

            gridItem.Tag = property;
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.Name));
            gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.Type));

            foreach (ArchAngel.Interfaces.ITemplate.IUserOption uo in property.Ex)
            {
                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
                {
                    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);
        }
Пример #6
0
        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);
        }