diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-11-27 21:51:38 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2017-11-27 21:51:38 +0200 |
| commit | df2f9b27b12356d6e92c64a72049f0fc4e6b86c0 (patch) | |
| tree | 049ced63087ef30986cc998f8546071e5894e37e /Software/Visual_Studio/Tango.Synchronization/Local/ExtensionMethods.cs | |
| parent | 7060dc80c707fc0441ff69fe4f899107cb3f6fc1 (diff) | |
| download | Tango-df2f9b27b12356d6e92c64a72049f0fc4e6b86c0.tar.gz Tango-df2f9b27b12356d6e92c64a72049f0fc4e6b86c0.zip | |
Started Remote <=> Local Synchronization... /;
Diffstat (limited to 'Software/Visual_Studio/Tango.Synchronization/Local/ExtensionMethods.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Synchronization/Local/ExtensionMethods.cs | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Synchronization/Local/ExtensionMethods.cs b/Software/Visual_Studio/Tango.Synchronization/Local/ExtensionMethods.cs new file mode 100644 index 000000000..8746f9146 --- /dev/null +++ b/Software/Visual_Studio/Tango.Synchronization/Local/ExtensionMethods.cs @@ -0,0 +1,88 @@ +using Tango.Synchronization; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Synchronization.Local +{ + internal static class SQLExtensions + { + /// <summary> + /// Gets the type of the SQL column. + /// </summary> + /// <param name="column">The column.</param> + /// <returns></returns> + public static String GetSQLType(this DataColumn column) + { + return column.ExtendedProperties[Constants.COLUMN_TYPE].ToString(); + } + + /// <summary> + /// Gets the information table. + /// </summary> + /// <param name="table">The table.</param> + /// <returns></returns> + public static DataTable GetInfoTable(this DataTable table) + { + return table.ExtendedProperties[Constants.TABLE_INFO] as DataTable; + } + + /// <summary> + /// Determines whether column is marked NOT NULL. + /// </summary> + /// <param name="column">The column.</param> + public static bool IsNotNull(this DataColumn column) + { + int value = int.Parse(column.ExtendedProperties[Constants.IS_NOT_NULL].ToString()); + return value == 0 ? false : true; + } + + /// <summary> + /// Gets the column default value. + /// </summary> + /// <param name="column">The column.</param> + /// <returns></returns> + public static String GetDefaultValue(this DataColumn column) + { + String def = column.ExtendedProperties[Constants.DEFAULT_VALUE].ToString(); + + double num = -1; + + if (double.TryParse(def, out num)) + { + return num.ToString(); + } + else + { + if (def.Contains("randomblob") || def.Contains("localtime")) + { + def = def.Insert(0, "("); + def = def.Insert(def.Length - 1, ")"); + } + return def; + } + } + + /// <summary> + /// Determines whether column definition has default value. + /// </summary> + /// <param name="column">The column.</param> + public static bool HasDefaultValue(this DataColumn column) + { + return !String.IsNullOrWhiteSpace(column.ExtendedProperties[Constants.DEFAULT_VALUE].ToString()); + } + + /// <summary> + /// Converts the DateTime instance to SQLite DateTime string. + /// </summary> + /// <param name="date">The date.</param> + /// <returns></returns> + public static String ToSQLiteDateString(this DateTime date) + { + return date.ToString("yyyy-MM-dd HH:mm:ss.fff"); + } + } +}
\ No newline at end of file |
