Hi all:
To put this in concise language...
Aim:
To create a class which can load and save a list of objects to/from a data source.
Current Method:
I have created a class which accepts two delegates as construction parameters:
private class Foo
{
public delegate List<object> LoadObjectsDelegate();
public delegate void SaveObjectsDelegate(List<object> data);
private LoadObjectsDelegate _loadDelegate;
private SaveObjectsDelegate _saveDelegate;
public Foo(LoadObjectsDelegate loadDelegate, SaveObjectsDelegate saveDelegate)
{
_loadDelegate = loadDelegate;
_saveDelegate = saveDelegate;
}
public List<object> Objects {get; private set;}
public void Load()
{
Objects = _loadDelegate.Invoke();
}
public void Save()
{
_saveDelegate.Invoke(Objects);
}
}
i was wondering if there was a cleaner way to do this.