public void ConvertValue(IBedValueReader reader, TypeStorage dsttype, IBedValueWriter writer) { var srctype = reader.GetFieldType(); if (srctype == dsttype) { // no conversion needed writer.ReadFrom(reader); return; } if (srctype.IsNumber() && dsttype.IsNumber()) { if (dsttype.IsInteger()) { writer.SetIntegerValue(dsttype, reader.GetIntegerValue()); } else { writer.SetRealValue(dsttype, reader.GetRealValue()); } return; } if (srctype.IsDateRelated() && dsttype.IsDateRelated()) { writer.SetDateTimeValue(dsttype, reader.GetDateTimeValue()); return; } if (srctype == TypeStorage.Boolean && dsttype.IsNumber()) { bool val = reader.GetBoolean(); writer.SetIntegerValue(dsttype, val ? 1 : 0); return; } if (srctype.IsNumber() && dsttype == TypeStorage.Boolean) { long val = reader.GetIntegerValue(); writer.SetBoolean(val != 0); return; } if (srctype == TypeStorage.String) { // parse m_parser.ParseValue(reader.GetString(), dsttype, writer); return; } if (dsttype == TypeStorage.String) { // format m_formatter.ReadFrom(reader); writer.SetString(m_formatter.GetText()); return; } { // most generic case - format and than parse m_formatter.ReadFrom(reader); m_parser.ParseValue(m_formatter.GetText(), dsttype, writer); return; } }
public void ConvertValue(ICdlValueReader reader, TypeStorage dsttype, ICdlValueWriter writer) { var srctype = reader.GetFieldType(); if (srctype == dsttype) { // no conversion needed writer.ReadFrom(reader); return; } if (srctype.IsNumber() && dsttype.IsNumber()) { if (dsttype.IsInteger()) { writer.SetIntegerValue(dsttype, reader.GetIntegerValue()); } else { writer.SetRealValue(dsttype, reader.GetRealValue()); } return; } if (srctype.IsDateRelated() && dsttype.IsDateRelated()) { writer.SetDateTimeValue(dsttype, reader.GetDateTimeValue()); return; } if (srctype == TypeStorage.Boolean && dsttype.IsNumber()) { bool val = reader.GetBoolean(); writer.SetIntegerValue(dsttype, val ? 1 : 0); return; } if (srctype.IsNumber() && dsttype == TypeStorage.Boolean) { long val = reader.GetIntegerValue(); writer.SetBoolean(val != 0); return; } if (srctype == TypeStorage.String) { // parse m_parser.ParseValue(reader.GetString(), dsttype, writer); return; } if (dsttype == TypeStorage.String) { // format m_formatter.ReadFrom(reader); writer.SetString(m_formatter.GetText()); return; } { // most generic case - format and than parse m_formatter.ReadFrom(reader); m_parser.ParseValue(m_formatter.GetText(), dsttype, writer); return; } }
public void WriteErrorDefault(TypeStorage type, ICdlValueWriter writer) { if (type.IsNumber()) { writer.SetIntegerValue(type, m_defaultNumber); } else if (type.IsDateRelated()) { writer.SetDateTimeValue(type, m_defaultDateTime); } else if (type == TypeStorage.Boolean) { writer.SetBoolean(m_defautlLogical); } else { writer.SetNull(); } }
public void WriteErrorDefault(TypeStorage type, ICdlValueWriter writer) { if (type.IsNumber()) writer.SetIntegerValue(type, m_defaultNumber); else if (type.IsDateRelated()) writer.SetDateTimeValue(type, m_defaultDateTime); else if (type == TypeStorage.Boolean) writer.SetBoolean(m_defautlLogical); else writer.SetNull(); }