This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DateTimeHelper | |
{ | |
private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | |
public static DateTime UnixTimeToDateTime(string text) | |
{ | |
double seconds = double.Parse(text, CultureInfo.InvariantCulture); | |
var time = Epoch.AddSeconds(seconds); | |
return time; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class SQLiteExtensions | |
{ | |
/// <summary> | |
/// Save the specified entity by calling insert or update, if the entity already exists. | |
/// </summary> | |
/// <param name="pk">The primary key of the entity</param> | |
/// <param name="obj">The instance of the entity</param> | |
/// <typeparam name="T">The entity type.</typeparam> | |
public static int Save<T>(this SQLiteConnection db, object pk, object obj) where T : class, new() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string ToSafeString(this object obj) | |
{ | |
if (obj == null) | |
{ | |
return string.Empty; | |
} | |
return obj.ToString(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static TValue GetValueOrDefault<TKey, TValue> (this IDictionary<TKey, TValue> dictionary, TKey key) | |
{ | |
TValue ret; | |
dictionary.TryGetValue(key, out ret); | |
return ret; | |
} |