Пример #1
0
        public void FillData(CustomProperty customProperty)
        {
            this.DialogResult = DialogResult.Cancel;
            EditType = EditTypes.CustomProperty;
            CustomProperty = customProperty;

            if (CustomProperty != null)
            {
                checkBoxAutoAddToEntities.Checked = customProperty.AutoAddToEntities;
                syntaxEditor1.Text = customProperty.UserString;
            }
            else
                throw new Exception("customProperty cannot be null.");
        }
Пример #2
0
        public void FillData(EditTypes editType)
        {
            this.DialogResult = DialogResult.Cancel;
            CustomProperty = null;
            CustomMethod = null;
            EditType = editType;
            checkBoxAutoAddToEntities.Checked = true;

            switch (EditType)
            {
                case EditTypes.CustomMethod:
                    syntaxEditor1.Text = "public void NewFunction()\n{\n}";
                    break;
                case EditTypes.CustomProperty:
                    syntaxEditor1.Text = "public string NewProperty { get; set; }";
                    break;
                default:
                    throw new NotImplementedException("Not handled yet: " + EditType.ToString());
            }
        }
Пример #3
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            string name;

            switch (EditType)
            {
                case EditTypes.CustomMethod:
                    ArchAngel.Providers.CodeProvider.DotNet.Function codeMethod;

                    try
                    {
                        if (!CustomFunction.CodeMethodIsValid(syntaxEditor1.Text, out name, out codeMethod))
                        {
                            MessageBox.Show(this, "The code is not valid. It has an error.", "Invalid code", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, "The code is not valid. It has an error.", "Invalid code", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (CustomMethod == null)
                        CustomMethod = new CustomFunction(name, syntaxEditor1.Text);
                    else
                    {
                        CustomMethod.Name = name;
                        CustomMethod.UserString = syntaxEditor1.Text;
                    }
                    CustomMethod.CodeFunction = codeMethod;
                    CustomMethod.AutoAddToEntities = checkBoxAutoAddToEntities.Checked;
                    break;
                case EditTypes.CustomProperty:

                    ArchAngel.Providers.CodeProvider.DotNet.Property codeProperty;

                    try
                    {
                        if (!CustomProperty.CodePropertyIsValid(syntaxEditor1.Text, out name, out codeProperty))
                        {
                            MessageBox.Show(this, "The code is not valid. It has an error.", "Invalid code", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, "The code is not valid. It has an error.", "Invalid code", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (CustomProperty == null)
                        CustomProperty = new CustomProperty(name, syntaxEditor1.Text);
                    else
                    {
                        CustomProperty.Name = name;
                        CustomProperty.UserString = syntaxEditor1.Text;
                    }
                    CustomProperty.CodeProperty = codeProperty;
                    CustomProperty.AutoAddToEntities = checkBoxAutoAddToEntities.Checked;
                    break;
                default:
                    throw new NotImplementedException("EditType not handled yet in buttonOk_Click(): " + EditType.ToString());
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }