public void TestReferenceUpdate()
        {
            var so1 = new SimpleObject {
                ValueOne = 1, ValueTwo = 2
            };
            var so2 = new SimpleObject {
                ValueOne = 3, ValueTwo = 4
            };
            var ro = new ReferenceObject {
                ReferenceOne = so1
            };

            var clone = (ReferenceObject)CopyUtils.CloneObjectTest(ro);

            clone.ReferenceOne = so2;

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());
            Assert.AreNotSame(ro.ReferenceOne, clone.ReferenceOne);

            CopyUtils.UpdateFromClone(ro, clone);

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());
            Assert.AreSame(ro.ReferenceOne, clone.ReferenceOne);
        }
Esempio n. 2
0
 bool filtRefObj(ReferenceObject refobj)
 {
     if (search.Current.IsNullOrEmpty())
     {
         return(true);
     }
     foreach (var kvFilter in search.filter.filters)
     {
         if (kvFilter.Key == "t" && refobj.GetType().FullName.ToLower().Contains(kvFilter.Value.ToLower()))
         {
             if (search.filter.value.IsNullOrEmpty())
             {
                 return(true);
             }
             else
             {
                 return(refobj.Data.GUID.ToLower().Contains(search.filter.value.ToLower()));
             }
         }
         else if (kvFilter.Key == "n" && refobj.name.ToLower().Contains(kvFilter.Value.ToLower()))
         {
             if (search.filter.value.IsNullOrEmpty())
             {
                 return(true);
             }
             else
             {
                 return(refobj.Data.GUID.ToLower().Contains(search.filter.value.ToLower()));
             }
         }
     }
     return(search.GeneralValid(refobj.Data.GUID));
 }
        public void TestReferenceClone()
        {
            var so = new SimpleObject {
                ValueOne = 1, ValueTwo = 2
            };
            var ro = new ReferenceObject {
                ReferenceOne = so
            };

            var clone = (ReferenceObject)CopyUtils.CloneObjectTest(ro);

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());

            Assert.AreSame(ro.ReferenceOne, clone.ReferenceOne);
        }
        public void TestReferenceUpdate() {
            var so1 = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var so2 = new SimpleObject {ValueOne = 3, ValueTwo = 4};
            var ro = new ReferenceObject {ReferenceOne = so1};

            var clone = (ReferenceObject) CopyUtils.CloneObjectTest(ro);
            clone.ReferenceOne = so2;

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());
            Assert.AreNotSame(ro.ReferenceOne, clone.ReferenceOne);

            CopyUtils.UpdateFromClone(ro, clone);

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());
            Assert.AreSame(ro.ReferenceOne, clone.ReferenceOne);
        }
        public void TestReferenceClone() {
            var so = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var ro = new ReferenceObject {ReferenceOne = so};

            var clone = (ReferenceObject) CopyUtils.CloneObjectTest(ro);

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());

            Assert.AreSame(ro.ReferenceOne, clone.ReferenceOne);
        }
 public override string ToString() => $"Property: {ReferenceObject.GetType().Name}, {OldValue} | {NewValue}";