DataFileSingleton
This commit is contained in:
parent
2f29c9b6bd
commit
ec7dc9e65a
@ -29,14 +29,12 @@ namespace JewelryStoreFileImplement
|
|||||||
"Components", x => x.GetXElement);
|
"Components", x => x.GetXElement);
|
||||||
public void SaveProducts() => SaveData(Products, ProductFileName,
|
public void SaveProducts() => SaveData(Products, ProductFileName,
|
||||||
"Products", x => x.GetXElement);
|
"Products", x => x.GetXElement);
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
=> x.GetXElement);
|
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
Components = LoadData(ComponentFileName, "Component", x =>
|
Components = LoadData(ComponentFileName, "Component", x =>
|
||||||
Component.Create(x)!)!;
|
Component.Create(x)!)!;
|
||||||
Products = LoadData(ProductFileName, "Product", x =>
|
Products = LoadData(ProductFileName, "Product", x => Jewel.Create(x)!)!;
|
||||||
Product.Create(x)!)!;
|
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
}
|
}
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
||||||
|
Loading…
Reference in New Issue
Block a user