public override async Task <CollectionBase <TDomainClass> > Load() { CollectionBase <TDomainClass> collection = new CollectionBase <TDomainClass>(); foreach (var obj in _objectSource.ObjectList) { collection.Insert(obj); } return(collection); }
/// <summary> /// Read model collection from file. /// The collection is returned by the method. /// </summary> /// <param name="fileName"> /// Data is read from this text file. /// </param> public static async Task <CollectionBase <TDomainClass> > Load(string fileName) { string modelAsString = await LoadFromFileAsync(fileName); CollectionBase <TDomainClass> collection = new CollectionBase <TDomainClass>(); if (modelAsString != null) { List <TDomainClass> list = (List <TDomainClass>)JsonConvert.DeserializeObject(modelAsString, typeof(List <TDomainClass>)); foreach (TDomainClass e in list) { collection.Insert(e, false); // Do not overwrite Key } } return(collection); }