IDataSource Interface
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Interface for all data sources.
public interface IDataSource
type IDataSource = interface
Public Interface IDataSource
- Derived
Remarks
A data source is any managed set of data that can be used to populate a data view via a data consumer. This data can be static or dynamic, with any changes being reported to any data consumers who have registered to receive change notifications.
Key concepts:
Key Path (string) - a unique accessor to specific data items within a data set. Although a Key Path can be any unique identifier per data item, all current implementations use the concept of a logical user readable specifier that indicates the navigational position of the data of interest relative to the entire data set. It is modelled on javascript's concept of lists, dictionaries and primitives, such that key paths are correct javascript statements for accessing data that can be represented in JSON. The advantage of this approach is that it correlates very well with both JSON and XML, which are the two most prevalent means of transferring information from back-end services. Example key paths:
temperature
contacts[10].firstName
contacts
contacts[10].addresses[3].city
[10].title
kingdom.animal.mammal.aardvark.diet.foodtypes.termites
Given that a key path is an arbitrary string with no required taxonomy, the actual data specifiers could be any method of describing what data to retrieve. XML's XPath is an example of a viable key path schema. As long as key paths provided by the data consumer are consistent with the key paths expected by the data source, everything will work. Furthermore Key Path Mappers can be implemented to translate between different schemas.
Resolving a keypath means combining two key paths: 1) a keypath describes how to access a specific subset of a larger dataset, such as one entry in a list of many entries, and 2) a partial (relative) keypath that represents just a datum within that list or map entry. This makes it possible to treat a subset of the data in such a way that it does not matter where in a larger data set hierarchy it actually exists. The most critical use of this ability is to describe the data of a single entry in a list without worrying about which entry in that list the current instance is referencing.
Key Path Mapper (IDataKeyPathMapper) - A dependency injected helper that can map between namespaces used in a data set and name spaces used in a view object, like a prefab meant to be re-usable with different data sources, like a contact list.
Data Consumer (IDataConsumer) - An object that knows how to consume information being managed by a data source and use that data to populate data views.
Data Consumer Listener - Data Consumers that have registered to be notified of any changes to a specific data item in a dataset. Whenever the data specified has changed (or suspected to have changed), the Data Consumer(s) will be notified.
Collection - Any subset of the data source that is a repeated array of the same types of information. This special consideration of the structure of the data is critical for populating list views where items are presented in a list. Data sources and data consumers can support nested lists, such as a list of keywords associated with each photo in a list of photos. The keypath for the keywords would be relative to the photo, and the keypath for the photos would be relative to the list, and the keypath of the list would be relative to either the nearest parent list, or the root of the data set.
Properties
| Name | Description |
|---|---|
| DataController |
An optional data controller. |
| DataSourceType |
Get the data source type |
Methods
| Name | Description |
|---|---|
| AddDataConsumerListener(String, IDataConsumer) |
Add a new data consumer listener for the specified key path |
| DataChangeSetBegin() |
Begin a data change set. |
| DataChangeSetEnd() |
End a data change set. |
| GetCollectionCount(String) |
If a key path represents a collection, return the number of items in that collection. |
| GetCollectionKeyPathRange(String, Int32, Int32) |
Get an enumerable collection of key path strings for the specified collection index range. |
| GetNthCollectionKeyPathAt(String, Int32) |
If a key path represents a collection, return a collection key path for the entry at index |
| GetValue(String) |
Get the value associated with the specified key path and prefix |
| IsCollectionAtKeyPath(String) |
Determine if key path represents a data collection |
| IsDataAvailable() |
Is data available in the data source. |
| NotifyAllChanged(DataChangeType, IDataConsumer) |
Notify all listeners that data has changed. |
| NotifyDataChanged(String, Object, DataChangeType, Boolean) |
Inform data source that its data has changed. |
| RemoveDataConsumerListener(String, IDataConsumer) |
Remove a data consumer listener for the specified key path |
| ResolveKeyPath(String, String) |
Resolve a key path using a given prefix and local path. |
| SetDataKeyPathMapper(IDataKeyPathMapper) |
Set a key path mapper. |
| SetValue(String, Object, Boolean) |
Set the value associated with the specified key path |