How can I add a constructor to my IncrementalLoadingCollection. I want to add a constructor to pass arguments to the GetPagedItemsAsync method to load data from an API.
My Incremental Loading Collection:
public class PeopleSource : IIncrementalSource<Person>
{
private readonly List<Person> people;
public PeopleSource(int maxValue)
{
// Creates an example collection.
people = new List<Person>();
for (int i = 1; i <= maxValue; i++)
{
var p = new Person { Name = "Person " + i };
people.Add(p);
}
}
public async Task<IEnumerable<Person>> GetPagedItemsAsync(int pageIndex, int pageSize)
{
// Gets items from the collection according to pageIndex and pageSize parameters.
var result = (from p in people
select p).Skip(pageIndex * pageSize).Take(pageSize);
// Simulates a longer request...
await Task.Delay(1000);
return result;
}
}
The above code is an example from Microsoft. There is a constructor for People which takes an Argument named maxValue.
var collection = new IncrementalLoadingCollection<PeopleSource, Person>();
The above code is an Initialization of the Incremental Loading class. But where do I pass on the maxValue Argument?? Please Help me...