Пример #1
0
 private void ValidateName(ValidationContext context)
 {
     if (!EscherAttributeContentValidator.IsValidCsdlPropertyName(Name))
     {
         var message = String.Format(CultureInfo.CurrentCulture, Resources.Error_PropertyNameInvalid, Name);
         context.LogError(message, Properties.Resources.ErrorCode_PropertyNameInvalid, this);
     }
 }
Пример #2
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            if (_needsValidation)
            {
                _needsValidation = false;

                if (!EscherAttributeContentValidator.IsValidCsdlEntityTypeName(entityNameTextBox.Text))
                {
                    VsUtils.ShowErrorDialog(DialogsResource.NewEntityDialog_InvalidEntityNameMsg);
                    e.Cancel = true;
                    entityNameTextBox.Focus();
                }
                else
                {
                    string msg;
                    if (!ModelHelper.IsUniqueName(typeof(EntityType), _model, entityNameTextBox.Text, false, out msg))
                    {
                        VsUtils.ShowErrorDialog(DialogsResource.NewEntityDialog_EnsureUniqueNameMsg);
                        e.Cancel = true;
                        entityNameTextBox.Focus();
                        return;
                    }

                    if (entitySetTextBox.Enabled)
                    {
                        if (!EscherAttributeContentValidator.IsValidCsdlEntitySetName(EntitySetName))
                        {
                            VsUtils.ShowErrorDialog(DialogsResource.NewEntityDialog_InvalidEntitySetMsg);
                            e.Cancel = true;
                            entitySetTextBox.Focus();
                            return;
                        }

                        if (!ModelHelper.IsUniqueName(typeof(EntitySet), _model.FirstEntityContainer, EntitySetName, false, out msg))
                        {
                            VsUtils.ShowErrorDialog(DialogsResource.NewEntityDialog_EnsureUniqueSetNameMsg);
                            e.Cancel = true;
                            entitySetTextBox.Focus();
                            return;
                        }
                    }

                    if (propertyNameTextBox.Enabled)
                    {
                        if (!EscherAttributeContentValidator.IsValidCsdlPropertyName(propertyNameTextBox.Text))
                        {
                            VsUtils.ShowErrorDialog(DialogsResource.NewEntityDialog_InvalidKeyPropertyNameMsg);
                            e.Cancel = true;
                            propertyNameTextBox.Focus();
                            return;
                        }
                        else if (propertyNameTextBox.Text.Equals(EntityName, StringComparison.Ordinal))
                        {
                            VsUtils.ShowErrorDialog(DialogsResource.SameEntityAndPropertyNameMsg);
                            e.Cancel = true;
                            propertyNameTextBox.Focus();
                            return;
                        }
                    }
                }
            }
        }