file implement done lab 6

This commit is contained in:
VictoriaPresnyakova 2023-04-17 18:26:54 +04:00
parent 28d03e79ed
commit 5ca87aa12f
2 changed files with 8 additions and 0 deletions

View File

@ -15,11 +15,14 @@ namespace JewelryStoreFileImplement
private readonly string OrderFileName = "Order.xml";
private readonly string JewelFileName = "Jewel.xml";
private readonly string ClientFileName = "Client.xml";
private readonly string ImplementerFileName = "Implementer.xml";
public List<Component> Components { get; private set; }
public List<Order> Orders { get; private set; }
public List<Jewel> Jewels { get; private set; }
public List<Client> Clients { get; private set; }
public List<Implementer> Implementers { get; private set; }
public static DataFileSingleton GetInstance()
{
@ -33,6 +36,8 @@ namespace JewelryStoreFileImplement
public void SaveJewels() => SaveData(Jewels, JewelFileName, "Jewels", x => x.GetXElement);
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
public void SaveClients() => SaveData(Clients, OrderFileName, "Clients", x => x.GetXElement);
public void SaveImplementers() => SaveData(Implementers, OrderFileName, "Implementers", x => x.GetXElement);
private DataFileSingleton()
{
@ -40,6 +45,8 @@ namespace JewelryStoreFileImplement
Jewels = LoadData(JewelFileName, "Jewel", x => Jewel.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
}
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)

View File

@ -2,6 +2,7 @@
using JewelryStoreContracts.SearchModels;
using JewelryStoreContracts.StoragesContracts;
using JewelryStoreContracts.ViewModels;
using JewelryStoreFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;