aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs')
-rw-r--r--Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs b/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs
new file mode 100644
index 000000000..56afb15b7
--- /dev/null
+++ b/Software/Visual_Studio/Tango.DataStore/DataStoreHelper.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.DataStore
+{
+ public static class DataStoreHelper
+ {
+ public static DataType GetDataType(Object value)
+ {
+ return GetDataType(value.GetType());
+ }
+
+ public static DataType GetDataType(Type type)
+ {
+ if (type == typeof(Int32))
+ {
+ return DataType.Int32;
+ }
+ else if (type == typeof(float))
+ {
+ return DataType.Float;
+ }
+ else if (type == typeof(double))
+ {
+ return DataType.Double;
+ }
+ else if (type == typeof(String))
+ {
+ return DataType.String;
+ }
+ else if (type == typeof(bool))
+ {
+ return DataType.Boolean;
+ }
+ else if (type == typeof(byte[]))
+ {
+ return DataType.Bytes;
+ }
+
+ throw new NotSupportedException($"The specified type '{type.Name}' is not supported by the data store.");
+ }
+
+ public static Type GetType(DataType type)
+ {
+ switch (type)
+ {
+ case DataType.Boolean:
+ return typeof(bool);
+ case DataType.Bytes:
+ return typeof(byte[]);
+ case DataType.Double:
+ return typeof(double);
+ case DataType.Float:
+ return typeof(float);
+ case DataType.Int32:
+ return typeof(Int32);
+ case DataType.String:
+ return typeof(String);
+ }
+
+ throw new NotSupportedException("The specified data type is not supported.");
+ }
+ }
+}