From 06fd7c27809e2b5979a09c023d2cd594494d6838 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 21 Jun 2016 18:20:55 +0200 Subject: [PATCH] starting ref refactor (need to merge first) --- .../Models/EntityBase/TracksChangesEntityBase.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Core/Models/EntityBase/TracksChangesEntityBase.cs b/src/Umbraco.Core/Models/EntityBase/TracksChangesEntityBase.cs index f2d57873b5..611039072c 100644 --- a/src/Umbraco.Core/Models/EntityBase/TracksChangesEntityBase.cs +++ b/src/Umbraco.Core/Models/EntityBase/TracksChangesEntityBase.cs @@ -173,14 +173,14 @@ namespace Umbraco.Core.Models.EntityBase /// save a document type, nearly all properties are flagged as dirty just because we've 'reset' them, but they are all set /// to the same value, so it's really not dirty. /// - internal T SetPropertyValueAndDetectChanges(T newVal, T origVal, PropertyInfo propertySelector) + internal void SetPropertyValueAndDetectChanges(T newVal, ref T origVal, PropertyInfo propertySelector) { if ((typeof(T) == typeof(string) == false) && TypeHelper.IsTypeAssignableFrom(typeof(T))) { throw new InvalidOperationException("This method does not support IEnumerable instances. For IEnumerable instances a manual custom equality check will be required"); } - return SetPropertyValueAndDetectChanges(newVal, origVal, propertySelector, EqualityComparer.Default); + SetPropertyValueAndDetectChanges(newVal, ref origVal, propertySelector, EqualityComparer.Default); } /// @@ -197,17 +197,16 @@ namespace Umbraco.Core.Models.EntityBase /// save a document type, nearly all properties are flagged as dirty just because we've 'reset' them, but they are all set /// to the same value, so it's really not dirty. /// - internal T SetPropertyValueAndDetectChanges(T newVal, T origVal, PropertyInfo propertySelector, IEqualityComparer comparer) + internal void SetPropertyValueAndDetectChanges(T newVal, ref T origVal, PropertyInfo propertySelector, IEqualityComparer comparer) { //don't track changes, just return the value - if (_changeTrackingEnabled == false) return newVal; + if (_changeTrackingEnabled == false) return; if (comparer.Equals(origVal, newVal) == false) { + origVal = newVal; OnPropertyChanged(propertySelector); } - - return newVal; } } } \ No newline at end of file