Exemple #1
0
        private void record(IObjectChange <TPrincipal> objectChange, string propertyName, Func <object> deferredValue, Func <object> oldValue)
        {
            IPropertyChange <TPrincipal> propertyChange = getPropertyChangeFor(objectChange, propertyName);

            if (deferredValue != null)
            {
                deferredValues.Store(objectChange, propertyName, deferredValue, oldValue);
            }
        }
 public UnknownPropertyInLogException(IPropertyChange <TPrincipal> propertyChange)
     : base(string.Format(
                message,
                (propertyChange != null ? propertyChange.PropertyName : "[Null]"),
                (propertyChange != null && propertyChange.ObjectChange != null ? propertyChange.ObjectChange.TypeName : "[Null]")
                ))
 {
     PropertyChange = propertyChange;
 }
        private void setValue(IPropertyChange <TPrincipal> propertyChange, object value)
        {
            string valueAsString = valueToString(value);
            int    valueAsInt;

            propertyChange.Value = valueAsString;
            if (int.TryParse(propertyChange.Value, out valueAsInt))
            {
                propertyChange.ValueAsInt = valueAsInt;
            }
        }
Exemple #4
0
        private IPropertyChange getChange(PropertyInfo propertyInfo, Snapshot original, Snapshot updated)
        {
            if (propertyInfo == null || !properties.ContainsKey(propertyInfo))
            {
                return(null);
            }
            var             propertyDetector = properties[propertyInfo];
            IPropertyChange change           = propertyDetector.GetChange(original, updated);

            return(change);
        }
Exemple #5
0
        public void ShouldDetectChangeToDerivedProperty_OriginalNull()
        {
            var           detector = new DerivedChangeDetector();
            DerivedEntity original = null;
            DerivedEntity updated  = new DerivedEntity()
            {
                DerivedValue = 234
            };

            var changes = detector.GetChanges(original, updated);

            Assert.AreEqual(1, changes.Count(), "The wrong number of changes were detected.");
            IPropertyChange change = changes.Single();

            Assert.AreEqual(DerivedChangeDetector.DerivedDescription, change.DisplayName, "The wrong property was recorded.");
            Assert.AreEqual(null, change.FormatOriginalValue(), "The old value was not recorded.");
            Assert.AreEqual(Formatters.FormatInt32(updated.DerivedValue), change.FormatUpdatedValue(), "The new value was not recorded.");
        }
Exemple #6
0
        public void ShouldDetectChangeToInheritedProperty()
        {
            var           detector = new DirectDerivedChangeDetector();
            DerivedEntity original = new DerivedEntity()
            {
                BooleanValue = false
            };
            DerivedEntity updated = new DerivedEntity()
            {
                BooleanValue = true
            };

            var changes = detector.GetChanges(original, updated);

            Assert.AreEqual(1, changes.Count(), "The wrong number of changes were detected.");
            IPropertyChange change = changes.Single();

            Assert.AreEqual("BooleanValue", change.DisplayName, "The wrong property was recorded.");
        }
Exemple #7
0
        public void ShouldDetectChange_UpdatedNull()
        {
            var        detector = new TestEntityChangeDetector();
            TestEntity original = new TestEntity()
            {
                StringValue = "After"
            };
            TestEntity updated = null;

            Assert.IsTrue(detector.HasChange(a => a.StringValue, original, updated), "No change detected for the property.");

            var changes = detector.GetChanges(original, updated);

            Assert.AreEqual(1, changes.Count(), "The wrong number of changes were detected.");
            IPropertyChange change = changes.Single();

            Assert.AreEqual(TestEntityChangeDetector.StringDescription, change.DisplayName, "The wrong property was recorded.");
            Assert.AreEqual(Formatters.FormatString(original.StringValue), change.FormatOriginalValue(), "The old value was not recorded.");
            Assert.AreEqual(null, change.FormatUpdatedValue(), "The new value was not recorded.");
        }
Exemple #8
0
        public void ShouldIncludeChangeToDoubleDerivedProperty()
        {
            var detector = new DoubleDerivedChangeDetector();
            DoubleDerivedEntity original = new DoubleDerivedEntity()
            {
                DoubleDerivedValue = "John"
            };
            DoubleDerivedEntity updated = new DoubleDerivedEntity()
            {
                DoubleDerivedValue = "Tom"
            };

            var changes = detector.GetChanges(original, updated);

            Assert.AreEqual(1, changes.Count(), "The wrong number of changes were detected.");
            IPropertyChange change = changes.Single();

            Assert.AreEqual(DoubleDerivedChangeDetector.DoubleDerivedDescription, change.DisplayName, "The wrong property was recorded.");
            Assert.AreEqual(Formatters.FormatString(original.DoubleDerivedValue), change.FormatOriginalValue(), "The old value was not recorded.");
            Assert.AreEqual(Formatters.FormatString(updated.DoubleDerivedValue), change.FormatUpdatedValue(), "The new value was not recorded.");
        }
 /// <summary>Inserts a change operation into an array at the specified position.</summary>
 /// <param name="iIndex">The index at which the change is inserted.</param>
 /// <param name="ppropChange">A pointer to the interface that contains the change.</param>
 void InsertAt([In] uint iIndex, [In] IPropertyChange ppropChange);
 public PropertyChangeProcessor(IPropertyChange <TPrincipal> wrapped)
 {
     this.wrapped = wrapped;
 }
Exemple #11
0
 void IObjectChange <Usuario> .Add(IPropertyChange <Usuario> propertyChange)
 {
     PropertyChanges.Add((PropertyChange)propertyChange);
 }
 public static extern HRESULT PSCreateSimplePropertyChange([In] PKA_FLAGS flags, [In] ref PROPERTYKEY key,
                                                           [In] PROPVARIANT propvar, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IPropertyChange ppv);
Exemple #13
0
 void IObjectChange <ApplicationUser> .Add(IPropertyChange <ApplicationUser> propertyChange)
 {
     PropertyChanges.Add((PropertyChange)propertyChange);
 }
Exemple #14
0
 void IObjectChange <User> .Add(IPropertyChange <User> propertyChange)
 {
     PropertyChanges.Add((PropertyChange)propertyChange);
 }
 /// <summary>Inserts a change operation at the end of an array.</summary>
 /// <param name="ppropChange">A pointer to the interface that contains the change.</param>
 void Append([In] IPropertyChange ppropChange);
 /// <summary>Replaces the first occurrence of a change that affects the same property key as the provided change. If the property key is not already in the array, this method appends the change to the end of the array.</summary>
 /// <param name="ppropChange">A pointer to the interface that contains the change.</param>
 void AppendOrReplace([In] IPropertyChange ppropChange);
 public void Add(IPropertyChange <TPrincipal> propertyChange)
 {
     throw new NotImplementedException();
 }