/// <summary> /// Converts the data to a string separated value /// </summary> /// <param name="split">the separation character to use between the data elements (default is \)</param> /// <returns>the data as a string</returns> public string ToString(string split = "\\") { if (MultipicityValue.Count > 1) { return(string.Join(split, MultipicityValue.ToArray())); } return(SingleValue != null?SingleValue.ToString() : ""); }
public override string ToString() { if (MultipicityValue.Count > 1) { return(string.Join(" | ", MultipicityValue.ToArray())); } return(SingleValue != null?SingleValue.ToString() : ""); }
public override string ToString() { var type = _typesStrings[(int)Type]; string value; switch (Type) { case IndexValueType.String: value = StringValue; break; case IndexValueType.StringArray: throw new NotSupportedException(); case IndexValueType.Bool: value = BooleanValue ? IndexValue.Yes : IndexValue.No; break; case IndexValueType.Int: value = IntegerValue.ToString(CultureInfo.InvariantCulture); break; case IndexValueType.IntArray: //throw new NotSupportedException(); //UNDONE: Investigate this modification because it can cause deserialization- or parsing errors. value = $"[{string.Join(",", IntegerArrayValue.Select(x => x.ToString()))}]"; break; case IndexValueType.Long: value = LongValue.ToString(CultureInfo.InvariantCulture); break; case IndexValueType.Float: value = SingleValue.ToString(CultureInfo.InvariantCulture); break; case IndexValueType.Double: value = DoubleValue.ToString(CultureInfo.InvariantCulture); break; case IndexValueType.DateTime: value = DateTimeValue.ToString("yyyy-MM-dd HH:mm:ss.ffff"); break; default: throw new ArgumentOutOfRangeException(); } return($"{value}:{type}"); }
string IConvertible.ToString(IFormatProvider provider) { switch (IntPtr.Size) { case 4: return(SingleValue.ToString(provider)); case 8: return(DoubleValue.ToString(provider)); default: throw GetError(); } }
public override string ToString() { switch (IntPtr.Size) { case 4: return(SingleValue.ToString()); case 8: return(DoubleValue.ToString()); default: throw GetError(); } }
public override string ToString() { var type = "SABILFDT"[(int)Type]; string value; switch (Type) { case IndexValueType.String: value = StringValue; break; case IndexValueType.StringArray: throw new NotSupportedException(); case IndexValueType.Bool: value = BooleanValue ? IndexValue.Yes : IndexValue.No; break; case IndexValueType.Int: value = IntegerValue.ToString(CultureInfo.InvariantCulture); break; case IndexValueType.Long: value = LongValue.ToString(CultureInfo.InvariantCulture); break; case IndexValueType.Float: value = SingleValue.ToString(CultureInfo.InvariantCulture); break; case IndexValueType.Double: value = DoubleValue.ToString(CultureInfo.InvariantCulture); break; case IndexValueType.DateTime: value = DateTimeValue.ToString("yyyy-MM-dd HH:mm:ss.ffff"); break; default: throw new ArgumentOutOfRangeException(); } return($"{value}:{type}"); }
private static DataValue ConvertSingle(SingleValue singleValue, DataType dataType, bool truncate) { switch (dataType) { case DataType.DataType_String: { return(new StringValue(singleValue.ToString())); } case DataType.DataType_Double: { return(new DoubleValue(Convert.ToDouble(singleValue.Single))); } case DataType.DataType_Decimal: { return(new DecimalValue(Convert.ToDouble(singleValue.Single))); } case DataType.DataType_Int16: { float f = singleValue.Single; try { short sh = Convert.ToInt16(f); return(new Int16Value(sh)); } catch (OverflowException) { if (truncate) { if (f > (float)short.MaxValue) { return(new Int16Value(short.MaxValue)); } else if (f < (float)short.MinValue) { return(new Int16Value(short.MinValue)); } else { return(new Int16Value((short)f)); } } } return(null); } case DataType.DataType_Int32: { if (truncate) { return(new Int32Value(Convert.ToInt32(singleValue.Single))); } else { return(null); } } case DataType.DataType_Int64: { if (truncate) { return(new Int64Value(Convert.ToInt64(singleValue.Single))); } else { return(null); } } default: return(null); } }
private static DataValue ConvertSingle(SingleValue singleValue, DataType dataType, bool truncate) { switch (dataType) { case DataType.DataType_String: { return new StringValue(singleValue.ToString()); } case DataType.DataType_Double: { return new DoubleValue(Convert.ToDouble(singleValue.Single)); } case DataType.DataType_Decimal: { return new DecimalValue(Convert.ToDouble(singleValue.Single)); } case DataType.DataType_Int16: { float f = singleValue.Single; try { short sh = Convert.ToInt16(f); return new Int16Value(sh); } catch (OverflowException) { if (truncate) { if (f > (float)short.MaxValue) return new Int16Value(short.MaxValue); else if (f < (float)short.MinValue) return new Int16Value(short.MinValue); else return new Int16Value((short)f); } } return null; } case DataType.DataType_Int32: { if (truncate) return new Int32Value(Convert.ToInt32(singleValue.Single)); else return null; } case DataType.DataType_Int64: { if (truncate) return new Int64Value(Convert.ToInt64(singleValue.Single)); else return null; } default: return null; } }