Extract running SQL from the resource

in the separate assembly. This allow breaking of the SQLite.sql into separate pieces later.
This commit is contained in:
Andrey Kurdyumov 2015-01-19 23:59:55 +06:00
parent e2604733f2
commit 40a5b7bc00

View file

@ -55,17 +55,26 @@ namespace Cosmos.Debug.Common {
internal void CreateDB() internal void CreateDB()
{ {
using (var strm = typeof(SQL).Assembly.GetManifestResourceStream(typeof(SQL), "SQLite.sql")) ExecuteAssemblyResource("SQLite.sql");
{ }
if (strm == null)
/// <summary>
/// Exceutes SQL file stored inside assembly.
/// </summary>
/// <param name="resourceName">Name of the assembly resource to execute.</param>
internal void ExecuteAssemblyResource(string resourceName)
{
using (var strm = typeof(SQL).Assembly.GetManifestResourceStream(typeof(SQL), resourceName))
{ {
throw new Exception("Sql resource not found!"); if (strm == null)
{
throw new Exception("Sql resource not found!");
}
using (var reader = new StreamReader(strm))
{
Exec(reader.ReadToEnd());
}
} }
using (var reader = new StreamReader(strm))
{
Exec(reader.ReadToEnd());
}
}
} }
} }
} }