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 DateTime FromUnixTime(this long unixTime) | |
{ | |
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | |
return epoch.AddSeconds(unixTime); | |
} | |
public static long ToUnixTime(this DateTime date) | |
{ | |
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | |
return Convert.ToInt64((date - epoch).TotalSeconds); |
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
using System; | |
using System.Collections.Generic; | |
namespace Comparers | |
{ | |
/// <summary> | |
/// Implements an equality comparer that allows the method implementations | |
/// to be supplied as functions in the constructor, eliminating the need | |
/// for a custom class to be implemented. | |
/// </summary> |
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
/// <summary> | |
/// Provides a wrapper method around <see cref="Enumerable.ToDictionary"/> to provide details about | |
/// the duplicate keys encountered (for troubleshooting purposes). | |
/// </summary> | |
public static class EnumerableHelper | |
{ | |
/// <summary> | |
/// Wraps the standard LINQ ToDictionary extension method to provide additional details about | |
/// the keys that were to be added to the dictionary. |
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.IO.Compression; | |
using System.Runtime.Serialization.Formatters.Binary; | |
namespace GMac.Serialization | |
{ | |
public static class SerializationHelper | |
{ |
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
// This class will not be serialized by protobuf-net because of the use of IEnumerable<T>: | |
[Serializable, ProtoContract] | |
public class GoalPlanningModel : ResourceModelBase | |
{ | |
[ProtoMember(1)] | |
public IEnumerable<ProposedGoal> ProposedGoals { get; set; } | |
[ProtoMember(2)] | |
public IEnumerable<PublishedGoal> PublishedGoals { get; set; } |