Beispiel #1
0
        public TObject Calculate <TObject>(ObjectDelta <TObject> delta) where TObject : class, IEquatable <TObject>, new()
        {
            var properties = typeof(TObject).GetProperties();
            var input      = delta.NewValue;
            var result     = new TObject();

            foreach (var propertyInfo in properties)
            {
                var propertyDelta = delta.Deltas.FirstOrDefault(x => x.Name == propertyInfo.Name);

                propertyInfo.SetValue(result, propertyDelta != null ? propertyDelta.Value : propertyInfo.GetValue(input));
            }

            return(result);
        }
Beispiel #2
0
 protected bool Equals(ObjectDelta <TObject> other)
 {
     return(EqualityComparer <TObject> .Default.Equals(NewValue, other.NewValue) && Deltas.OrderBy(t => t.Name).SequenceEqual(other.Deltas.OrderBy(t => t.Name)));
 }