/// <summary> /// Constructor that allows to create a object, /// as a "shallow" copy of another object. /// It maintains, the two-step initialization, /// and two step finalization, technique, /// with virtual constructors & destructors. /// </summary> /// <param name="Source">Source object</param> /// <returns>Error Code, <code>0<code> if succesful.</returns> public virtual Int64 CreateCopy(CloneableObjectClass Source) { Int64 Result = 0; // --> execute inherited constructor Result = base.Create(); // --> allocate fields if (Result == 0) { // ... } // if (Result == 0) // --> update status F_CloneableObjectClass_IsReady = true; // --> special case this.AssignFrom(Source); return Result; }
/// <summary> /// When an object of this class is instantiated, /// creates & returns a "Shallow" copy of itself. /// </summary> /// <returns>"Shallow" copy of the object.</returns> public virtual CloneableObjectClass Clone() { CloneableObjectClass Result = new CloneableObjectClass(); Result.Create(); Result.AssignFrom(this); return Result; }
/// <summary> /// Copies all value properties from the current object, /// to <code>ADest</code>. /// </summary> /// <param name="ADest"></param> public void AssignTo(CloneableObjectClass ADest) { ADest.AssignFrom(this); }
// ... /// <summary> /// Copies all value properties from <code>ASource</code>, /// to the current object. /// </summary> /// <param name="ASource">Object to be used as a template</param> public virtual void AssignFrom(CloneableObjectClass ASource) { this.DoNothing(); }
// ... /// <summary> /// Copies all value properties from <code>ASource</code>, /// to the current object. /// </summary> /// <param name="ASource">Object to be used as a template</param> public override void AssignFrom(CloneableObjectClass ASource) { if (this.IsReady()) { if (ASource != null) { FilterListClass Data = (ASource as FilterListClass); foreach (FilterClass EachSourceFilter in Data.InternalList) { FilterClass EachDestFilter = (FilterClass)EachSourceFilter.Clone(); this.Add(EachDestFilter); } // foreach } // if (ASource != null) } // if (this.IsReady()) }
// ... /// <summary> /// Copies all value properties from <code>ASource</code>, /// to the current object. /// </summary> /// <param name="ASource">Object to be used as a template</param> public override void AssignFrom(CloneableObjectClass ASource) { if (this.IsReady()) { if (ASource != null) { FilterClass Data = (ASource as FilterClass); this.ConcatOperator = Data.ConcatOperator; this.Key = Data.Key; this.Operation = Data.Operation; this.Value = Data.Value; this.IsExpression = Data.IsExpression; } // if (ASource != null) } // if (this.IsReady()) }