private static DotNetType GetDotNetTypeinternalFromDatabaseType(List <DatabaseTypeMap> maps, string typeName, Utility.DatabaseTypes databaseType)
        {
            DatabaseTypeMap map = maps.SingleOrDefault(m => m.TypeName.ToLowerInvariant() == typeName.ToLowerInvariant());

            if (map != null)
            {
                return(map.DotNetType);
            }

            FormCustomType form = new FormCustomType(typeName, databaseType);

            form.ShowDialog();
            return(form.DotNetType);
        }
Beispiel #2
0
        private static void AddMap(List <DatabaseTypeMap> mapCollection, XmlNodeList nodes)
        {
            foreach (XmlNode node in nodes)
            {
                string typeName       = node.Attributes["type"].Value;
                string dotnetTypeName = node.Attributes["dotnet"].Value;

                DotNetType      dotnetType = DotNetTypes.SingleOrDefault(t => t.Name.ToLowerInvariant() == dotnetTypeName.ToLowerInvariant());
                DatabaseTypeMap map        = mapCollection.SingleOrDefault(c => c.TypeName.ToLowerInvariant() == typeName.ToLowerInvariant());

                if (map != null)
                {
                    map.DotNetType = dotnetType;
                }
                else
                {
                    mapCollection.Add(new DatabaseTypeMap(typeName, dotnetType));
                }
            }
        }
Beispiel #3
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (checkBoxExisting.Checked && comboBoxCSharpTypes.SelectedItem == null)
            {
                MessageBox.Show(this, "Please select a .Net type.", "Missing value", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (checkBoxNew.Checked && (string.IsNullOrWhiteSpace(textBoxDotNetType.Text) || string.IsNullOrWhiteSpace(textBoxCSharpType.Text)))
            {
                MessageBox.Show(this, "You need to enter .Net and C# types.", "Missing values", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            DotNetType dotnetType = null;

            if (checkBoxExisting.Checked)
            {
                dotnetType = Utility.DotNetTypes.SingleOrDefault(testc => testc.Name == comboBoxCSharpTypes.Text);
            }
            else
            {
                Utility.DotNetTypes.SingleOrDefault(t => t.Name.ToLowerInvariant() == textBoxDotNetType.Text.Trim().ToLowerInvariant());

                if (dotnetType == null)
                {
                    dotnetType = new DotNetType()
                    {
                        Name = textBoxDotNetType.Text.Trim(), CSharpName = textBoxCSharpType.Text.Trim()
                    };
                    ArchAngel.Interfaces.ProjectOptions.TypeMappings.Utility.DotNetTypes.Add(dotnetType);
                }
            }
            List <DatabaseTypeMap> maps;

            switch (Database)
            {
            case Utility.DatabaseTypes.Firebird:
                maps = Utility.FirebirdTypes;
                break;

            case Utility.DatabaseTypes.MySql:
                maps = Utility.MySqlTypes;
                break;

            case Utility.DatabaseTypes.Oracle:
                maps = Utility.OracleTypes;
                break;

            case Utility.DatabaseTypes.PostgreSql:
                maps = Utility.PostgreSqlTypes;
                break;

            case Utility.DatabaseTypes.SqlServer:
                maps = Utility.SqlServerTypes;
                break;

            case Utility.DatabaseTypes.SQLite:
                maps = Utility.SQLiteTypes;
                break;

            default:
                throw new NotImplementedException("Database type not handled yet: " + Database.ToString());
            }
            DatabaseTypeMap newDBType = new DatabaseTypeMap("", null);

            newDBType.TypeName   = labelDatabaseType.Text;
            newDBType.DotNetType = dotnetType;
            maps.Add(newDBType);
            DotNetType = dotnetType;
            Utility.SaveSettings();
            Close();
        }
Beispiel #4
0
        private static bool CreateMapNode(XmlDocument doc, XmlNode sqlServerMapsNode, bool changesExist, DatabaseTypeMap dbType)
        {
            if (SaveUnmodified || dbType.IsModified)
            {
                changesExist = true;
                string dotnetTypeName = dbType.DotNetType == null ? "" : dbType.DotNetType.Name;

                XmlNode mapNode = doc.CreateElement("map");
                AddAttribute(doc, mapNode, "type", dbType.TypeName);
                AddAttribute(doc, mapNode, "dotnet", dotnetTypeName);
                sqlServerMapsNode.AppendChild(mapNode);
            }
            return(changesExist);
        }