Add commands for Broker, autosave and clean logging

This commit is contained in:
2019-04-27 11:29:31 +02:00
parent f67d070fc3
commit d8c7a9e2c5
6 changed files with 75 additions and 7 deletions

View File

@@ -1,12 +1,13 @@
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace PlantBox.Broker
{
class PlantBoxesManager
class PlantBoxesManager : IEnumerable<PlantBox>
{
public string FilePath => Path.Combine(Environment.CurrentDirectory, FileName);
public string FileName => "storage.json";
@@ -70,5 +71,17 @@ namespace PlantBox.Broker
Console.WriteLine("Storage saved");
}
public void ClearPlantBox(PlantBox plantBox)
{
if (plantBox != null)
{
plantBox.HistoricManager.Clear();
}
}
public IEnumerator<PlantBox> GetEnumerator() => _plantBoxes.Values.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}