I would need a revision of the code for the next implementation. Is this code safe? What can we improve?
The purpose of this code is for the study.
Public class Repository: IRepository, IDisposable
{
private IStorage _storage;
private list the entrees;
Public repository (IStorage storage)
{
_storage = storage;
_entries = storage.Load (). ToList ();
}
public void Create (input)
{
_entries.Add (entry);
}
public void Update (Enter)
{
existing var = _entries.Where (x => x.ID == entry.ID) .FirstOrDefault ();
existing name.name = entry.name;
existing.Number = entry.Number;
existing.Type = entry.Type;
}
public void Delete (Enter)
{
_entries = _entries.Where (x => x.ID! = entry.ID) .ToList ();
}
public entry GetEntry (Guid ID)
{
return _entries.FirstOrDefault (x => x.ID == ID);
}
public IEnumerable GetAlphabetically (Func support)
{
return _entries.OrderBy (x => prop (x));
}
public void Save ()
{
_storage.Persist (_entries);
}
private bool disposed = false;
public void Dispose ()
{
Eliminate (true);
GC.SuppressFinalize (this);
}
protected virtual empty Dispose (bool disposing)
{
if (! disposed)
{
if (dispose)
{
if (_entries! = null)
_entries = null;
}
willing = true;
}
}
~ Repository ()
{
Eliminate (false);
}
}