-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobals.cs
More file actions
33 lines (27 loc) · 934 Bytes
/
Globals.cs
File metadata and controls
33 lines (27 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Collections.ObjectModel;
using System.Linq;
using SoftwareProject.Types;
using SoftwareProject.ViewModels;
using Splat;
namespace SoftwareProject
{
public static class Globals
{
public static Database CurrentDatabase = new();
public static ObservableCollection<Stock> CachedStocks { get; } = new();
public static MainWindowViewModel MainWindow { get; } = new();
public static Stock? GetStock(string shortName)
{
var stock = CachedStocks.FirstOrDefault(s =>
s.ShortName == shortName);
if (stock == null)
{
stock = CurrentDatabase.GetStockFromDb(shortName);
if (stock == null) return null;
CachedStocks.Add(stock);
}
return stock;
}
public static ILogger Logs = new ConsoleLogger {Level = LogLevel.Debug};
}
}