DataSources always provide data on an Out stream. The Provide method makes it very easy to do.
This is part of the new API for DataSources released in 2sxc 9.13.
How to use
In general, you need to
- have a private method - usually called GetList() that would return a list of items, if it is called
- use that GetList() to build a stream, which has a name - typically Default
- attach that stream to the Out so that it's accessible
Here's a simple example of the constructor of the DnnFormAndList DataSource, which provides the default stream:
Using Provide in the Constructor
public DnnFormAndList()
{
// Specify what out-streams this data-source provides. Usually just one, called "Default"
Provide(GetList); // does everything
// ...
}
private IEnumerable<Eav.Interfaces.IEntity> GetList()
{
// ...
}
This example ensures that the .Out["Default"] as well as the .List (which is a shorthand for .Out[Constants.DefaultStreamName].List) are mounted, ready to deliver.
More Docs and Advanced Use Cases
Of course you can do more :). To read about that, check out the wiki-documentation of the Provide helper.
Love from Switzerland
Daniel