Skip to content

Commit

Permalink
Make Dialect.GetTransformationProvider strongly typed
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesfoster committed Feb 19, 2011
1 parent 26e42b5 commit 6638149
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/Migrator.Providers/Dialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ protected Dialect()
RegisterProperty(ColumnProperty.PrimaryKey, "PRIMARY KEY");
}

public abstract Type TransformationProvider { get; }
public abstract ITransformationProvider GetTransformationProvider(Dialect dialect, string connectionString);

public ITransformationProvider NewProviderForDialect(string connectionString)
{
return (ITransformationProvider) Activator.CreateInstance(TransformationProvider, this, connectionString);
return GetTransformationProvider(this, connectionString);
}

/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion src/Migrator.Providers/Impl/Mysql/MysqlDialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ public MysqlDialect()
RegisterProperty(ColumnProperty.Identity, "AUTO_INCREMENT");
}

public override Type TransformationProvider { get { return typeof(MySqlTransformationProvider); } }
public override ITransformationProvider GetTransformationProvider(Dialect dialect, string connectionString)
{
return new MySqlTransformationProvider(dialect, connectionString);
}

public override string QuoteTemplate
{
Expand Down
8 changes: 5 additions & 3 deletions src/Migrator.Providers/Impl/Oracle/OracleDialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public OracleDialect()
RegisterProperty(ColumnProperty.Null, String.Empty);
}

public override Type TransformationProvider { get { return typeof(OracleTransformationProvider); } }

}
public override ITransformationProvider GetTransformationProvider(Dialect dialect, string connectionString)
{
return new OracleTransformationProvider(dialect, connectionString);
}
}
}
7 changes: 5 additions & 2 deletions src/Migrator.Providers/Impl/PostgreSQL/PostgreSQLDialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ public PostgreSQLDialect()
RegisterProperty(ColumnProperty.Identity, "serial");
}

public override Type TransformationProvider { get { return typeof(PostgreSQLTransformationProvider); } }

public override ITransformationProvider GetTransformationProvider(Dialect dialect, string connectionString)
{
return new PostgreSQLTransformationProvider(dialect, connectionString);
}

public override bool TableNameNeedsQuote
{
get { return false; }
Expand Down
5 changes: 4 additions & 1 deletion src/Migrator.Providers/Impl/SQLite/SQLiteDialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public SQLiteDialect()
RegisterProperty(ColumnProperty.Identity, "AUTOINCREMENT");
}

public override Type TransformationProvider { get { return typeof(SQLiteTransformationProvider); } }
public override ITransformationProvider GetTransformationProvider(Dialect dialect, string connectionString)
{
return new SQLiteTransformationProvider(dialect, connectionString);
}

public override bool NeedsNotNullForIdentity
{
Expand Down
10 changes: 6 additions & 4 deletions src/Migrator.Providers/Impl/SqlServer/SqlServer2005Dialect.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
using System;
using System.Data;
using Migrator.Framework;

namespace Migrator.Providers.SqlServer
{
public class SqlServer2005Dialect : SqlServerDialect
{
public SqlServer2005Dialect() :base()
public SqlServer2005Dialect()
{
RegisterColumnType(DbType.AnsiString, 2147483647, "VARCHAR(MAX)");
RegisterColumnType(DbType.Binary, 2147483647, "VARBINARY(MAX)");
RegisterColumnType(DbType.String, 1073741823, "NVARCHAR(MAX)");
RegisterColumnType(DbType.Xml, "XML");
}

public override Type TransformationProvider { get { return typeof (SqlServerTransformationProvider); } }

public override ITransformationProvider GetTransformationProvider(Dialect dialect, string connectionString)
{
return new SqlServerTransformationProvider(dialect, connectionString);
}
}
}
17 changes: 10 additions & 7 deletions src/Migrator.Providers/Impl/SqlServer/SqlServerCeDialect.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
using System;
using System.Data;
using Migrator.Framework;

namespace Migrator.Providers.SqlServer
{
public class SqlServerCeDialect : SqlServerDialect
{
public class SqlServerCeDialect : SqlServerDialect
{
public SqlServerCeDialect()
{
{
RegisterColumnType(DbType.AnsiStringFixedLength, "NCHAR(255)");
RegisterColumnType(DbType.AnsiStringFixedLength, 4000, "NCHAR($l)");
RegisterColumnType(DbType.AnsiString, "NVARCHAR(255)");
RegisterColumnType(DbType.AnsiString, 4000, "NVARCHAR($l)");
RegisterColumnType(DbType.AnsiString, 1073741823, "TEXT");
}
}

public override Type TransformationProvider { get { return typeof (SqlServerCeTransformationProvider); } }
public override ITransformationProvider GetTransformationProvider(Dialect dialect, string connectionString)
{
return new SqlServerCeTransformationProvider(dialect, connectionString);
}

}
}
}
5 changes: 4 additions & 1 deletion src/Migrator.Providers/Impl/SqlServer/SqlServerDialect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ public SqlServerDialect()
RegisterProperty(ColumnProperty.Identity, "IDENTITY");
}

public override Type TransformationProvider { get { return typeof(SqlServerTransformationProvider); } }
public override ITransformationProvider GetTransformationProvider(Dialect dialect, string connectionString)
{
return new SqlServerTransformationProvider(dialect, connectionString);
}

public override bool SupportsIndex
{
Expand Down

0 comments on commit 6638149

Please sign in to comment.