Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/24/10 00:23:16 (14 years ago)
Author:
hmayr
Message:

following changes (#1046):

  • extended DatabaseUtil.cs
  • extended HeuristicLabUser.cs
  • created HeuristicLabUserTest.cs
  • created AbstractHeuristicLabTest.cs
  • implemented a demo method in HeuristicLabMembershipProvider.cs to show usage of HeuristicLabUser.cs and DatabaseUtil.cs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Services.Authentication Prototype/Persistence/DatabaseUtil.cs

    r3940 r3943  
    1 namespace Persistence {
     1using System;
     2
     3namespace Persistence {
    24  /// <summary>
    3   ///
     5  /// combines multiple used static methods into one class
    46  /// </summary>
    57  public class DatabaseUtil {
    68    /// <summary>
    7     ///
     9    /// creates and returns a database connection, if possible
    810    /// </summary>
    9     /// <returns></returns>
     11    /// <returns>database connection (could be null)</returns>
    1012    public static DataClassesDataContext createDataClassesDataContext() {
    11       return new Persistence.DataClassesDataContext(@"C:\TEMP\HeuristicLabTemp.mdf");
     13      DataClassesDataContext db;
     14      try {
     15        db = new Persistence.DataClassesDataContext(@"C:\TEMP\HeuristicLabTemp.mdf");
     16      }
     17      catch (Exception) {
     18        return null;
     19      }
     20      return db;
     21    }
     22
     23    /// <summary>
     24    /// creates a new database out of the LINQ to SQL classes
     25    /// </summary>
     26    /// <param name="db">DataClassesDataContext</param>
     27    public static void createDatabase(DataClassesDataContext db) {
     28      if (db == null) {
     29        throw new ArgumentNullException("db");
     30      }
     31     
     32      if (db.DatabaseExists()) {
     33        Console.WriteLine("Deleting old database...");
     34        db.DeleteDatabase();
     35        Console.WriteLine("Deleted old database!");
     36      }
     37
     38      Console.WriteLine("Creating new database...");
     39      db.CreateDatabase();
     40      Console.WriteLine("Created new database!");
    1241    }
    1342  }
Note: See TracChangeset for help on using the changeset viewer.