public void LoadFileData() { bool DataSuccessfullyLoaded = false; if (File.Exists(filepath)) { using (FileStream fileStream = new FileStream(filepath, FileMode.Open)) { try { FileData = serializer.Unpack(fileStream) as FileData; DataSuccessfullyLoaded = true; Debug.Log(filepath + ": Successfully Loaded!"); } catch { Debug.Log(filepath + ": [ERROR] File Failed to Load!"); } } } else { Debug.Log(filepath + ": [WARNING] File not found!"); } if (!DataSuccessfullyLoaded) { Debug.Log("Loading Default Values into Save Profile..."); FileData = new FileData(); DefaultDataGenerator.LoadAll(); Debug.Log("Default Values have been Loaded."); } }
public static void Main(string[] args) { //CreateHostBuilder(args).Build().Run(); var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var context = services.GetRequiredService <BookContext>(); DefaultDataGenerator.Initialize(services); } host.Run(); }