Holds the values of an Item when reading a TeaFile untyped.
Namespace: TeaTimeAssembly: DiscreteLogics.TeaFiles (in DiscreteLogics.TeaFiles.dll) Version: 1.0.0.16 (1.0.0.16)
Syntax
public class Item
Remarks
If the type inside a TeaFile is not knnown or not available in the program, the file can be read untyped using TeaFile. In contrast to TeaFile<(Of <(<'T>)>)> which exposes each item by it's known type like Tick, TeaFile exposes the items as a collection of instances of this Item class. It wraps an array of objects, each holding the value of a field of the item. This item can be printed by calling its ToString()()()() method, or using GetValueString(Item) from ItemDescription.Examples
CopyC#
struct Tick { public Time Time; public double Price; public long Volume; } ... // write typed using (var tf = TeaFile<Tick>.Create("acme.tea")) { tf.Write(new Tick { Time = new Time(2000, 3, 4), Price = 12.34, Volume = 7200 }); } // 1. read typed using (var tf = TeaFile<Tick>.OpenRead("acme.tea")) { Tick item = tf.Read(); // typed read is convenient: we get a tpyed Tick back, Time t = item.Time; // so access to its fields simply means acessing the fields of a Tick struct. double p = item.Price; long v = item.Volume; } // 2. read untyped // if we do not have the type available or do not know what is inside the file, // we can still read it untyped: using (var tf = TeaFile.OpenRead("acme.tea")) { Item item = tf.Read(); // Here an item of type Item is returned, which holds the field values as an object[]. object t = item.Values[0]; // The field values can be accessed by their field index object p = item.Values[1]; // The values inside this array still have the types Time, double and long, but object v = item.Values[2]; // we might not always know this at compile time. If we know it, // a casts can be added: Time tt = (Time) item.Values[0]; Console.WriteLine(item); // The implicit call of ToString() here will cause the output: // 4.3.2000, 12.34, 7200 }