Example #1
0
 /// <summary>
 /// Creates a new restore index
 /// </summary>
 /// <param name="path">
 /// The path to the restore index file to create
 /// </param>
 /// <param name="header">
 /// The restore index header to insert
 /// </param>
 /// <returns>
 /// A new restore index implementation
 /// </returns>
 public static IRestoreIndex Create(IO.Path path, Header header)
 {
     // create the restore index file and schema
      Database.Create(path, "SkyFloe.Sqlite.Resources.RestoreIndex.sql");
      var index = (RestoreIndex)null;
      try
      {
     // connect to the database and add the header row
     index = new RestoreIndex(path);
     index.Execute(
        "INSERT INTO Header (" +
           "Version) " +
        "VALUES (@p0);",
        header.Version = CurrentVersion
     );
     return index;
      }
      catch
      {
     if (index != null)
        index.Dispose();
     try { Database.Delete(path); } catch { }
     throw;
      }
 }
Example #2
0
 /// <summary>
 /// Connects to an existing restore index database
 /// </summary>
 /// <param name="path">
 /// The path to the restore index to open
 /// </param>
 /// <returns>
 /// A new restore index implementation
 /// </returns>
 public static IRestoreIndex Open(IO.Path path)
 {
     var index = new RestoreIndex(path);
      if (index.FetchHeader().Version != CurrentVersion)
     throw new InvalidOperationException("Invalid database version");
      return index;
 }