// Copy from another instance over the top of an already existing instance. public virtual void CopyFrom(AbstractBase other) { if (other == null) { throw new ArgumentNullException("other"); } this.copyFrom(other); }
// Copy constructor. protected AbstractBase(AbstractBase other) { if (other == null) { throw new ArgumentNullException("other"); } this.copyFrom(other); }
static Derived2 Clone(AbstractBase item) { AbstractBase abstractBase = (AbstractBase)item.Clone(); Derived2 result = abstractBase as Derived2; Debug.Assert(result != null); return(result); }
// Equality check. public override bool Equals(object obj) { if (obj == null) { return(false); } if (object.ReferenceEquals(this, obj)) { return(true); } if (this.GetType() != obj.GetType()) { return(false); } AbstractBase other = (AbstractBase)obj; return(this.IntValue == other.IntValue); }
// Copy from another instance over the top of an already existing instance. public override void CopyFrom(AbstractBase other) { base.CopyFrom(other); this.copyFrom(other as Derived2); }
// Implement copying fields in a private non-virtual method, called from more than one place. private void copyFrom(AbstractBase other) // 'other' cannot be null, so no check for nullness is made. { this.IntValue = other.IntValue; }