예제 #1
0
 /// <summary>
 /// Instantiate or Overwrite the Singleton with a copy from a file
 /// This chould be called before any components access `Default()`
 ///
 /// DESIGN REVIEW: This method is a race condition with the first access of `Default()`
 ///                TODO: replace this in-memory collection with a real database
 /// </summary>
 public static void InitializeFromFile(string fileName)
 {
     _default = new AlbumCollection(fileName);
 }
예제 #2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     AlbumCollection.InitializeFromFile("../albums.csv");
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
 }
예제 #3
0
 /// <summary>
 /// Returns the singleton instance of an AlbumCollection, that may have been pre-loaded
 /// `InitializeFromFile`
 /// </summary>
 public static AlbumCollection Default() => _default ?? (_default = new AlbumCollection(null));