Generate some more row types with new t4 templates
This commit is contained in:
1 parent
d28e70cd37
commit
611d21d112
27 files changed
+1599
-303
No files matched your search
@@ -19,6 +19,8 @@ using Newtonsoft.Json;
|
||||
using BCG;
|
||||
using System.Runtime.CompilerServices;
|
||||
using bts;
|
||||
using Spark.Core;
|
||||
using System.Numerics;
|
||||
|
||||
namespace bts {
|
||||
|
||||
@@ -91,13 +93,13 @@ namespace BCG {
|
||||
return BlueDataUtility.get_row_datetime_value(r, col_no, err_value);
|
||||
}
|
||||
|
||||
public static double? GetDouble(this IBlueRow r, int colNo) =>
|
||||
GetDouble(r[colNo]);
|
||||
public static double? GetFloat64(this IBlueRow r, int colNo) =>
|
||||
GetFloat64(r[colNo]);
|
||||
|
||||
public static double? GetDouble(this IBlueRow r, string colName) =>
|
||||
GetDouble(r[colName]);
|
||||
public static double? GetFloat64(this IBlueRow r, string colName) =>
|
||||
GetFloat64(r[colName]);
|
||||
|
||||
public static double? GetDouble(object obj) {
|
||||
public static double? GetFloat64(object obj) {
|
||||
if (obj is double d) {
|
||||
return d;
|
||||
}
|
||||
@@ -125,6 +127,97 @@ namespace BCG {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int? GetInt32(this IBlueRow r, int colNo) =>
|
||||
GetInt32(r[colNo]);
|
||||
|
||||
public static int? GetInt32(this IBlueRow r, string colName) =>
|
||||
GetInt32(r[colName]);
|
||||
|
||||
public static int? GetInt32(object obj) {
|
||||
checked {
|
||||
if (obj is double d) {
|
||||
return (int)d;
|
||||
}
|
||||
if (obj is int i32) {
|
||||
return i32;
|
||||
}
|
||||
if (obj is long i64) {
|
||||
return (int)i64;
|
||||
}
|
||||
if (obj is string s) {
|
||||
return double.TryParse(s, out d) ? (int)d : null;
|
||||
}
|
||||
if (obj is uint u32) {
|
||||
return (int)u32;
|
||||
}
|
||||
if (obj is ulong u64) {
|
||||
return (int)u64;
|
||||
}
|
||||
if (obj is short i16) {
|
||||
return i16;
|
||||
}
|
||||
if (obj is ushort u16) {
|
||||
return u16;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static long? GetInt64(this IBlueRow r, int colNo) =>
|
||||
GetInt64(r[colNo]);
|
||||
|
||||
public static long? GetInt64(this IBlueRow r, string colName) =>
|
||||
GetInt64(r[colName]);
|
||||
|
||||
public static long? GetInt64(object obj) {
|
||||
checked {
|
||||
if (obj is double d) {
|
||||
return (long)d;
|
||||
}
|
||||
if (obj is int i32) {
|
||||
return i32;
|
||||
}
|
||||
if (obj is long i64) {
|
||||
return i64;
|
||||
}
|
||||
if (obj is string s) {
|
||||
return double.TryParse(s, out d) ? (long)d : null;
|
||||
}
|
||||
if (obj is uint u32) {
|
||||
return u32;
|
||||
}
|
||||
if (obj is ulong u64) {
|
||||
return (long)u64;
|
||||
}
|
||||
if (obj is short i16) {
|
||||
return i16;
|
||||
}
|
||||
if (obj is ushort u16) {
|
||||
return u16;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static DateTime? GetUnixEpochDateTime(this IBlueRow row, string colName) =>
|
||||
GetUnixEpochDateTime(row[colName]);
|
||||
|
||||
public static DateTime? GetUnixEpochDateTime(this IBlueRow row, int colNo) =>
|
||||
GetUnixEpochDateTime(row[colNo]);
|
||||
|
||||
public static DateTime? GetUnixEpochDateTime(object obj) {
|
||||
var tsNanos = GetInt64(obj);
|
||||
return tsNanos.HasValue ? DateTime.UnixEpoch.Add(new TimeSpan(tsNanos.Value / 100)) : null;
|
||||
}
|
||||
|
||||
public static DateTime? GetDateTime(object obj) {
|
||||
var res = _get_datetime_value(obj, DateTime.MinValue);
|
||||
if (res == DateTime.MinValue) {
|
||||
return null;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static T get_enum<T>(this IBlueRow r, string col_name, T err_value = default(T)) where T : struct {
|
||||
return BlueDataUtility.get_row_enum_value<T>(r, col_name, err_value);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user