/// <summary> /// Write value, efficiently casting to proper type as required by WriteValue /// </summary> /// <param name="tw"></param> /// <param name="vo"></param> /// <param name="typeId"></param> void StdfWriteValue( StdfTableWriter tw, StdfValueType type, object vo) { if (vo == null) { tw.WriteValue(null); StdfValueString += "null, "; } else { switch (type.TypeId) { case StdfValueTypeId.BoolType: tw.WriteValue((bool)vo); break; case StdfValueTypeId.IntType: tw.WriteValue((int)vo); break; case StdfValueTypeId.LongType: tw.WriteValue((long)vo); break; case StdfValueTypeId.FloatType: tw.WriteValue((float)vo); break; case StdfValueTypeId.DoubleType: tw.WriteValue((double)vo); break; case StdfValueTypeId.DateTimeType: tw.WriteValue((DateTime)vo); break; case StdfValueTypeId.DateType: tw.WriteValue((DateTime)vo); break; case StdfValueTypeId.StringType: tw.WriteValue((String)vo); break; case StdfValueTypeId.DecimalType: tw.WriteValue((Decimal)vo); break; case StdfValueTypeId.UnknownType: case StdfValueTypeId.TimeType: case StdfValueTypeId.TimeSpanType: case StdfValueTypeId.BinaryType: default: tw.WriteValue(null); break; } StdfValueString += vo.ToString() + "\r\n"; } StdfWriteValueCount++; return; }
public SpotfireDataFileTableWriter(string outputFile, SpotfireDataFileTableMetadata metadata) { if (metadata.StdfMd != null) { TextStream = File.OpenWrite(outputFile); StdfTw = new StdfTableWriter(TextStream, metadata.StdfMd); // open the text writer and write the metadata } if (metadata.SbdfMd != null) { BinaryStream = File.OpenWrite(outputFile); BinaryWriter = new BinaryWriter(BinaryStream); SbdfFileHeader.WriteCurrentVersion(BinaryWriter); // write file header metadata.SbdfMd.Write(BinaryWriter); // write the metadata SbdfTw = new SbdfTableWriter(BinaryWriter, metadata.SbdfMd); } return; }