Create a new TeaFile for type T.
Namespace: TeaTimeAssembly: DiscreteLogics.TeaFiles (in DiscreteLogics.TeaFiles.dll) Version: 1.0.0.16 (1.0.0.16)
Syntax
public static TeaFile<T> Create( string path, string contentDescription, NameValueCollection nameValues, bool includeItemDescription )
Parameters
- path
- Type: System..::..String
path of the file.
- contentDescription
- Type: System..::..String
A string describing the content. Defaults to null.
- nameValues
- Type: TeaTime..::..NameValueCollection
A collectiion of name values describing the content. Defaults to null.
- includeItemDescription
- Type: System..::..Boolean
Specifies if the item description is written into the file.
Return Value
A new instance of TeaFile<(Of <(<'T>)>)>.Remarks
Calling this methods creates a new file and writes the file header holding a description of T. The returned TeaFile{T} instance is in open state, read for writing.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; }
Exceptions
Exception | Condition |
---|---|
System..::..ArgumentNullException | Thrown when one or more required arguments are null. |