コード例 #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);
            }
        }
コード例 #2
0
 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;
 }
コード例 #3
0
        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;
            }
        }
コード例 #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);
        }
コード例 #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.");
        }
コード例 #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.");
        }
コード例 #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.");
        }
コード例 #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.");
        }
コード例 #9
0
 /// <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);
コード例 #10
0
 public PropertyChangeProcessor(IPropertyChange <TPrincipal> wrapped)
 {
     this.wrapped = wrapped;
 }
コード例 #11
0
 void IObjectChange <Usuario> .Add(IPropertyChange <Usuario> propertyChange)
 {
     PropertyChanges.Add((PropertyChange)propertyChange);
 }
コード例 #12
0
 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);
コード例 #13
0
 void IObjectChange <ApplicationUser> .Add(IPropertyChange <ApplicationUser> propertyChange)
 {
     PropertyChanges.Add((PropertyChange)propertyChange);
 }
コード例 #14
0
ファイル: ObjectChange.cs プロジェクト: pennsong/OB
 void IObjectChange <User> .Add(IPropertyChange <User> propertyChange)
 {
     PropertyChanges.Add((PropertyChange)propertyChange);
 }
コード例 #15
0
 /// <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);
コード例 #16
0
 /// <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);
コード例 #17
0
 public void Add(IPropertyChange <TPrincipal> propertyChange)
 {
     throw new NotImplementedException();
 }