Example #1
0
 protected void UpdateChange <TProperty>(
     Expression <Func <TObject, TProperty> > changedPropertyNameExpr,
     ValueObjectEditorViewModel <TProperty> editor)
 //where TProperty : class
     where TProperty : ValueObject <TProperty>
 {
     this.UpdateChange(changedPropertyNameExpr.GetMemberName(), editor, changedPropertyNameExpr.Compile());
 }
Example #2
0
        protected void UpdateChange <TProperty>(
            string propertyName,
            ValueObjectEditorViewModel <TProperty> editor,
            Func <TObject, TProperty> originalValueGetter)
        //where TProperty : class
            where TProperty : ValueObject <TProperty>
        {
            var originalValue =
                this._originalObject != null
                ? originalValueGetter(this._originalObject)
                : default;

            var newValue = editor.GetEditedValue();

            var isChanged = object.Equals(originalValue, newValue) == false;

            if (isChanged)
            {
                var changes = editor.GetChanges();

                if (this._changes.ContainsKey(propertyName))
                {
                    this._changes[propertyName] = changes;
                }
                else
                {
                    this._changes.Add(propertyName, changes);
                }
            }
            else
            {
                if (this._changes.ContainsKey(propertyName))
                {
                    this._changes.Remove(propertyName);
                }
            }
        }