コード例 #1
0
 public static bool ReferenceTemplate_IsValid(SourceCodeMultiLineType value, out string failReason)
 {
     failReason = "";
     return(true);
 }
コード例 #2
0
ファイル: Options.cs プロジェクト: uQr/Visual-NHibernate
        private void Options_ValueChanged(object sender, EventArgs e)
        {
            if (!Controller.Instance.BusyPopulating)
            {
                string failReason;

                if (!CheckOptionValue((Control)sender, out failReason))
                    MessageBox.Show("The value you have entered is invalid: " + failReason, "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                else
                {
                    IOption option = (IOption)((Control)sender).Tag;

                    if (option.VarType == typeof(int))
                        SharedData.CurrentProject.SetUserOption(option.VariableName, ((TextBox)sender).Text);
                    else if (option.VarType == typeof(string))
                        SharedData.CurrentProject.SetUserOption(option.VariableName, ((TextBox)sender).Text);
                    else if (option.VarType == typeof(bool))
                        SharedData.CurrentProject.SetUserOption(option.VariableName, ((CheckBox)sender).Checked);
                    else if (option.VarType == typeof(SourceCodeMultiLineType))
                    {
                        SourceCodeMultiLineType var = new SourceCodeMultiLineType(((ActiproSoftware.SyntaxEditor.SyntaxEditor)sender).Document.Text);
                        SharedData.CurrentProject.SetUserOption(option.VariableName, var);
                    }
                    else if (option.VarType == typeof(SourceCodeType))
                    {
                        SourceCodeType var = new SourceCodeType(((ActiproSoftware.SyntaxEditor.SyntaxEditor)sender).Document.Text);
                        SharedData.CurrentProject.SetUserOption(option.VariableName, var);
                    }
                    else if (option.VarType == typeof(bool?))
                    {
                        ComboBox combo = (ComboBox)sender;

                        if (string.IsNullOrEmpty(combo.Text))
                            SharedData.CurrentProject.SetUserOption(option.VariableName, null);
                        else
                            SharedData.CurrentProject.SetUserOption(option.VariableName, bool.Parse(((ComboBox)sender).Text));
                    }
                    else if (option.VarType == typeof(int?))
                    {
                        TextBox tb = (TextBox)sender;

                        if (string.IsNullOrEmpty(tb.Text))
                            SharedData.CurrentProject.SetUserOption(option.VariableName, null);
                        else
                            SharedData.CurrentProject.SetUserOption(option.VariableName, int.Parse(((TextBox)sender).Text));
                    }
                    else if (option.VarType == typeof(ArchAngel.NHibernateHelper.BytecodeGenerator))
                    {
                        ArchAngel.NHibernateHelper.BytecodeGenerator var = (ArchAngel.NHibernateHelper.BytecodeGenerator)Enum.Parse(typeof(ArchAngel.NHibernateHelper.BytecodeGenerator), ((ComboBox)sender).Text, true);
                        SharedData.CurrentProject.SetUserOption(option.VariableName, var);
                    }
                    else if (option.VarType == typeof(TopLevelCascadeTypes))
                    {
                        TopLevelCascadeTypes var = (TopLevelCascadeTypes)Enum.Parse(typeof(TopLevelCascadeTypes), ((ComboBox)sender).Text, true);
                        SharedData.CurrentProject.SetUserOption(option.VariableName, var);
                    }
                    else if (option.VarType == typeof(TopLevelCollectionCascadeTypes))
                    {
                        TopLevelCollectionCascadeTypes var = (TopLevelCollectionCascadeTypes)Enum.Parse(typeof(TopLevelCollectionCascadeTypes), ((ComboBox)sender).Text, true);
                        SharedData.CurrentProject.SetUserOption(option.VariableName, var);
                    }
                    else if (option.VarType == typeof(ArchAngel.NHibernateHelper.VisualStudioVersions))
                    {
                        ArchAngel.NHibernateHelper.VisualStudioVersions var = (ArchAngel.NHibernateHelper.VisualStudioVersions)Enum.Parse(typeof(ArchAngel.NHibernateHelper.VisualStudioVersions), ((ComboBox)sender).Text, true);
                        SharedData.CurrentProject.SetUserOption(option.VariableName, var);
                    }
                    else if (option.VarType == typeof(ArchAngel.NHibernateHelper.NHibernateVersions))
                    {
                        ArchAngel.NHibernateHelper.NHibernateVersions var = (ArchAngel.NHibernateHelper.NHibernateVersions)Enum.Parse(typeof(ArchAngel.NHibernateHelper.NHibernateVersions), ((ComboBox)sender).Text, true);
                        SharedData.CurrentProject.SetUserOption(option.VariableName, var);
                    }
                    else if (option.VarType == typeof(TopLevelAccessTypes))
                    {
                        TopLevelAccessTypes var = (TopLevelAccessTypes)Enum.Parse(typeof(TopLevelAccessTypes), ((ComboBox)sender).Text, true);
                        SharedData.CurrentProject.SetUserOption(option.VariableName, var);
                    }
                    else if (option.VarType == typeof(TopLevelCascadeTypes))
                    {
                        TopLevelCascadeTypes var = (TopLevelCascadeTypes)Enum.Parse(typeof(TopLevelCascadeTypes), ((ComboBox)sender).Text, true);
                        SharedData.CurrentProject.SetUserOption(option.VariableName, var);
                    }
                    else
                        throw new NotImplementedException("Option type not handled yet: " + option.VarType.Name);
                }
                Controller.Instance.IsDirty = true;
            }
        }