Persistence: Overload LoadList for loading of multiple types
This commit is contained in:
@@ -23,11 +23,26 @@ namespace Scrummer.Code.BusinessLogic
|
||||
#region public methods
|
||||
|
||||
public static List<T> LoadList<T>(string file)
|
||||
{
|
||||
return LoadList<T>(file, null);
|
||||
}
|
||||
|
||||
public static List<T> LoadList<T>(string file, List<Type> types)
|
||||
{
|
||||
List<T> listResult = new List<T>();
|
||||
JSONParser parser = new JSONParser();
|
||||
parser.KnownTypes.Add(typeof(T));
|
||||
|
||||
Type typeResult = typeof(T);
|
||||
if (typeResult.IsInterface == false)
|
||||
{
|
||||
parser.KnownTypes.Add(typeof(T));
|
||||
}
|
||||
if (types != null)
|
||||
{
|
||||
foreach (Type type in types)
|
||||
{
|
||||
parser.KnownTypes.Add(type);
|
||||
}
|
||||
}
|
||||
string filePath = GetLocalPath(file);
|
||||
if (File.Exists(filePath) == false) { return listResult; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user