コード例 #1
0
 // 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);
 }
コード例 #2
0
 // Copy constructor.
 protected AbstractBase(AbstractBase other)
 {
     if (other == null)
     {
         throw new ArgumentNullException("other");
     }
     this.copyFrom(other);
 }
コード例 #3
0
        static Derived2 Clone(AbstractBase item)
        {
            AbstractBase abstractBase = (AbstractBase)item.Clone();
            Derived2     result       = abstractBase as Derived2;

            Debug.Assert(result != null);
            return(result);
        }
コード例 #4
0
        // 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);
        }
コード例 #5
0
 // 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);
 }
コード例 #6
0
 // 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;
 }