Beispiel #1
0
        private static void LoadSettings(string xml)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            foreach (XmlNode node in doc.SelectNodes(@"type-maps/unitypes/unitype"))
            {
                string name       = node.Attributes["name"].Value;
                string csharpType = node.Attributes["csharp-type"].Value;

                UniType uniType = UniTypes.SingleOrDefault(u => u.Name.ToLowerInvariant() == name.ToLowerInvariant());

                if (uniType != null)
                {
                    uniType.CSharpType = csharpType;
                }
                else
                {
                    UniTypes.Add(new UniType(name, csharpType));
                }
            }
            AddMap(SqlServerTypes, doc.SelectNodes(@"type-maps/sql-server-maps/map"));
            AddMap(OracleTypes, doc.SelectNodes(@"type-maps/oracle-maps/map"));
            AddMap(MySqlTypes, doc.SelectNodes(@"type-maps/mysql-maps/map"));
            AddMap(PostgreSqlTypes, doc.SelectNodes(@"type-maps/postgresql-maps/map"));
            AddMap(FirebirdTypes, doc.SelectNodes(@"type-maps/firebird-maps/map"));
        }
Beispiel #2
0
        private static void AddMap(List <DatabaseTypeMap> mapCollection, XmlNodeList nodes)
        {
            foreach (XmlNode node in nodes)
            {
                string typeName    = node.Attributes["type"].Value;
                string uniTypeName = node.Attributes["unitype"].Value;

                UniType         uniType = UniTypes.SingleOrDefault(t => t.Name.ToLowerInvariant() == uniTypeName.ToLowerInvariant());
                DatabaseTypeMap map     = mapCollection.SingleOrDefault(c => c.TypeName.ToLowerInvariant() == typeName.ToLowerInvariant());

                if (map != null)
                {
                    map.UniType = uniType;
                }
                else
                {
                    mapCollection.Add(new DatabaseTypeMap(typeName, uniType));
                }
            }
        }