Exemplo n.º 1
0
        void ICloneExplicit.SetupCloneTargets(object target, ICloneTargetSetup setup)
        {
            ExplicitCloneTestObjectA targetCast = target as ExplicitCloneTestObjectA;

            setup.HandleObject(this.ListField, targetCast.ListField);
            setup.HandleObject(this.ListField2, targetCast.ListField2);
            setup.HandleObject(this.DictField, targetCast.DictField);
        }
Exemplo n.º 2
0
        void ICloneExplicit.CopyDataTo(object targetObj, ICloneOperation operation)
        {
            ExplicitCloneTestObjectA target = targetObj as ExplicitCloneTestObjectA;

            target.StringField = this.StringField;
            target.DataField   = this.DataField;
            operation.HandleObject(this.ListField, ref target.ListField);
            operation.HandleObject(this.ListField2, ref target.ListField2);
            operation.HandleObject(this.DictField, ref target.DictField);
        }
Exemplo n.º 3
0
		[Test] public void ExplicitCloning()
		{
			Random rnd = new Random();
			{
				ExplicitCloneTestObjectA data = new ExplicitCloneTestObjectA(rnd, 5);
				ExplicitCloneTestObjectA dataResult = data.DeepClone();
				
				Assert.IsTrue(data.Equals(dataResult));
				Assert.IsFalse(data.AnyReferenceEquals(dataResult));
			}
			{
				ExplicitCloneTestObjectB data = new ExplicitCloneTestObjectB(rnd, 5);
				ExplicitCloneTestObjectB dataResult = data.DeepClone();
				
				Assert.IsTrue(data.Equals(dataResult));
				Assert.IsFalse(data.AnyReferenceEquals(dataResult));
				Assert.IsFalse(data.SpecialSetupDone);
				Assert.IsTrue(dataResult.SpecialSetupDone);
			}
			{
				ExplicitCloneTestObjectC data = new ExplicitCloneTestObjectC(rnd, 5);
				ExplicitCloneTestObjectC dataResult = data.DeepClone();
				
				Assert.IsFalse(data.Equals(dataResult));
				Assert.IsFalse(data.AnyReferenceEquals(dataResult));
			}
		}