BlueCollar.SQLiteRepository.EnsureDatabase C# (CSharp) Метод

EnsureDatabase() защищенный статический Метод

Ensures that the SQLite database at the given path exists, creating it if it doesn't.
protected static EnsureDatabase ( string path ) : void
path string The path of the SQLite database to ensure.
Результат void
        protected static void EnsureDatabase(string path)
        {
            if (!File.Exists(path))
            {
                string sql;
                Stream stream = null;

                try
                {
                    stream = typeof(SQLiteRepository).Assembly.GetManifestResourceStream("BlueCollar.SQLite.Schema.sql");

                    using (StreamReader reader = new StreamReader(stream))
                    {
                        stream = null;
                        sql = reader.ReadToEnd();
                    }
                }
                finally
                {
                    if (stream != null)
                    {
                        stream.Dispose();
                    }
                }

                using (SQLiteConnection connection = new SQLiteConnection(string.Concat("data source=", path, ";journal mode=Off;synchronous=Off;version=3")))
                {
                    connection.Open();
                    connection.Execute(sql, null);
                }
            }
        }