private PointData FieldCleaner(PointData point, string key, object obj) { if (obj is int) { return(point.Field(key, (int)obj)); } if (obj is uint) { return(point.Field(key, (uint)obj)); } if (obj is double) { return(point.Field(key, (double)obj)); } if (obj is long) { return(point.Field(key, (long)obj)); } if (obj is ulong) { return(point.Field(key, (ulong)obj)); } //if(obj is string) { return point.Field(key,"\"" + (string)obj+ "\""); } if (obj is string) { throw new InvalidInfluxDBFieldValueException("string is not a valid type yet"); } if (obj is float) { return(point.Field(key, (float)obj)); } if (obj is decimal) { return(point.Field(key, (decimal)obj)); } if (obj is byte) { return(point.Field(key, (byte)obj)); } throw new InvalidInfluxDBFieldValueException($"Field {key} had an invalid type of {obj.GetType().Name}"); }
public PointData AppendFieldValue(PointData pointData, string field, double value) { return(pointData.Field(field, value)); }
protected virtual PointData WriteField(PointData point, string name, object value) { if (value == null) { return(point); } switch (value) { case bool boolValue: return(point.Field(name, boolValue)); case byte byteValue: return(point.Field(name, byteValue)); case sbyte sbyteValue: return(point.Field(name, sbyteValue)); case short shortValue: return(point.Field(name, shortValue)); case ushort ushortValue: return(point.Field(name, ushortValue)); case int intValue: return(point.Field(name, intValue)); case uint uintValue: return(point.Field(name, uintValue)); case long longValue: return(point.Field(name, longValue)); case ulong ulongValue: return(point.Field(name, ulongValue)); case float floatValue: return(point.Field(name, floatValue)); case double doubleValue: return(point.Field(name, doubleValue)); case string stringValue: return(point.Field(name, stringValue)); default: return(point); } }