private void okBtn_Click(object sender, EventArgs e)
        {
            if (!NamingGuidance.CheckMappedPropertyName(tbNewName.Text.Trim(), true))
            {
                tbNewName.SelectAll();
                tbNewName.Focus();
                return;
            }

            if (MaxPropertyLength > 0 &&
                tbNewName.Text.Trim().Length > MaxPropertyLength)
            {
                MessageBox.Show("The new name is too long! Maximum " + MaxPropertyLength.ToString() + " characters.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!string.IsNullOrEmpty(NameSuffix) &&
                !tbNewName.Text.Trim().EndsWith(NameSuffix, false, null))
            {
                MessageBox.Show(string.Format("The new name is missing the suffix (\"{0}\")!", NameSuffix), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            NewName = tbNewName.Text.Trim();

            DialogResult = DialogResult.OK;
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!NamingGuidance.CheckMappedPropertyName(tbName.Text, true))
            {
                return;
            }

            Property      = new Property();
            Property.Name = tbName.Text.Trim();

            Property.BusinessEntity = _businessEntity;

            if (rbString.Checked)
            {
                Property.Type = typeof(string);
            }
            else if (rbInt.Checked)
            {
                Property.Type = typeof(int);
            }
            else if (rbInt64.Checked)
            {
                Property.Type = typeof(long);
            }
            else if (rbDouble.Checked)
            {
                Property.Type = typeof(double);
            }
            else if (rbDecimal.Checked)
            {
                Property.Type = typeof(decimal);
            }
            else if (rbBoolean.Checked)
            {
                Property.Type = typeof(bool);
            }
            else if (rbDateTime.Checked)
            {
                Property.Type = typeof(DateTime);
            }

            DialogResult = DialogResult.OK;
        }
        private void CheckMappedProperties(PropertyMap propertyMap)
        {
            List <string> propNames = new List <string>();

            foreach (MappedProperty prop in propertyMap.MappedProperties)
            {
                if (prop.Target == null)
                {
                    throw new ArgumentException("Property is not mapped.", prop.Source.Name);
                }

                string name = prop.Name;

                if (string.IsNullOrEmpty(name))
                {
                    name = prop.Target.Name;
                }

                if (prop.TargetProperty != null)
                {
                    if (prop.TargetProperty.BusinessEntity == null)
                    {
                        throw new ArgumentException("Property has no BusinessEntity.", prop.Name);
                    }
                }

                // Check the names
                NamingGuidance.CheckMappedPropertyName(name, false);

                if (propNames.Contains(name))
                {
                    throw new ArgumentException("Duplicate property name.", name);
                }
                else
                {
                    propNames.Add(name);
                }
            }
        }
Ejemplo n.º 4
0
        private void sourceGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            MappedProperty property = sourceGrid.SelectedObject as MappedProperty;

            if (e.ChangedItem.PropertyDescriptor.Name == "DefaultValue")
            {
                if (!string.IsNullOrEmpty(property.DefaultValue))
                {
                    property.IsEnabled = true;
                }
            }

            if (e.ChangedItem.PropertyDescriptor.Name == "Name")
            {
                if (e.ChangedItem.Value != null)
                {
                    if (!NamingGuidance.CheckMappedPropertyName(e.ChangedItem.Value.ToString(), true))
                    {
                        property.Name = (e.OldValue == null ? null : e.OldValue.ToString());
                    }
                }
            }

            if (!MultiSelMode)
            {
                foreach (ListViewItem item in propertyListView.Items)
                {
                    UpdateListItem(item);
                }
            }
            else
            {
                // Save all changes so we can save all later
                ChangedMultiSelProperties[e.ChangedItem.PropertyDescriptor.Name] = e.ChangedItem.Value;
            }
        }