Compare-Net-Objects
Compare-Net-Objects copied to clipboard
Add DateOnly support
Would be nice to have this built in to the library, currently using this custom converter:
using System;
using KellermanSoftware.CompareNetObjects;
using KellermanSoftware.CompareNetObjects.TypeComparers;
namespace BestConnection.Application.Auditing
{
public class DateOnlyComparer : BaseTypeComparer
{
public DateOnlyComparer(RootComparer rootComparer) : base(rootComparer)
{
}
public override bool IsTypeMatch(Type type1, Type type2)
{
return type1 == typeof(DateOnly) || type2 == typeof(DateOnly);
}
public override void CompareType(CompareParms parms)
{
var date1 = (DateOnly?)parms.Object1;
var date2 = (DateOnly?)parms.Object2;
if (date1 != date2)
{
parms.Result.Differences.Add(new Difference()
{
PropertyName = parms.BreadCrumb,
Object1 = date1?.ToString("yyyy-MM-dd"),
Object2 = date2?.ToString("yyyy-MM-dd")
});
}
}
}
}
@sebasijan This is a great idea. I will put that in there.
Hello, @GregFinzer I'm looking to make some valuable pull requests for Octoberfest. I use this project at work and at home, and I would gladly help with some maintenance during the event (https://hacktoberfest.com/participation/#contributors)