Data |
The DataSpecs type exposes the following members.
Name | Description | |
---|---|---|
DataSpecs(DataSpec) | Constructs a DataSpecs object containing the specified DataSpec objects. | |
DataSpecs(IEnumerableDataSpec) | Constructs a DataSpecs object containing the specified DataSpec objects. |
Name | Description | |
---|---|---|
Count | Gets the number of DataSpec objects held by this DataSpecs - always greater than zero. | |
Item | Gets the non-null DataSpec that has been assigned the specified string key. | |
Keys | Gets the read-only collection of string keys that are assigned to the DataSpec objects stored within this DataSpecs. |
Name | Description | |
---|---|---|
Equals |
Two DataSpecs objects are equal if they contain the same set
of unique DataSpec objects - neither Keys nor the order of
keys make any difference.
(Overrides ObjectEquals(Object)) | |
GetEnumerator | Returns an enumerator for iterating over each DataSpec contained within this DataSpecs. | |
GetHashCode |
Overridden to ensure consistency with Equals.
(Overrides ObjectGetHashCode) | |
GetKey | Returns the non-null, non-empty string key associated with dataSpec. | |
ToString |
Returns a non-null, non-empty string representation of this instance for logging and debugging purposes.
(Overrides ObjectToString) |
When requesting multiple sets of data for a particular location, it makes sense to use multiple DataSpec objects to retrieve as much data as possible in a single request. This is cheaper and faster than fetching the same data across multiple requests. For example, for a particular location you might want to request heating and cooling degree days at 5 different base temperatures each. This would require 10 different DataSpec objects in total. By putting all 10 DataSpec objects in a single DataSpecs object, you could fetch all 10 sets of data in a single request.
For most use cases, all you will ever need to do with this class is use the constructors to create instances to pass into LocationDataRequest objects. However, if you are customizing this framework (e.g. using it to construct requests but handling the response XML using your own system entirely), you will probably find it useful to understand about keys and the uniqueness of DataSpec objects.
The XML request (which this .NET framework generates internally) requires that each DataSpec be assigned a unique string key attribute so that its corresponding data set can be found in the XML response (which this .NET framework parses internally). This DataSpecs class is central to the way that the keys are created and managed. It essentially gives you two options for key management:
There is no point in submitting a request containing multiple identical DataSpec objects, as it would lead to unnecessary duplication in the results and unnecessary bandwidth usage for the communication between the client and API servers.
Unless you are specifying your own keys (using DataSpecsCustomKeyBuilder), this class is set up to prevent duplicate DataSpec objects from being submitted as part of a request. It does this by filtering and discarding all duplicate DataSpec objects passed in to the constructors of this class. So, if you pass 10 DataSpec objects to one of the constructors, and only 5 of those are unique, then only the 5 unique DataSpec objects will be stored internally and sent as part of the XML request.
Because discarded duplicate DataSpec objects are identical to their retained counterparts, you can still use the duplicates to retrieve fetched data out of the LocationDataResponse. In other words, the internal process of filtering and discarding duplicate DataSpec objects should not affect the way in which you use this API.
If you create your own keys using DataSpecsCustomKeyBuilder, then duplicate DataSpec objects are not filtered. Filtering duplicate DataSpec objects would also involve filtering the keys associated with the duplicates, and this could cause problems for code of yours that was expecting those keys in the XML response. You can rely on the fact that, if you define your own DataSpec keys using CustomKeyBuilder, your XML response will contain entries for all of your keys, irrespective of whether some of the data associated with those keys is duplicated.