/// <summary> /// Pushes changes since the last <c>BeginEdit</c> or <c>IBindingList.AddNew</c> call into the underlying object. /// </summary> void IEditableObject.EndEdit() { //Console.WriteLine("Start EndEdit" + this.custData.id + this.custData.lastName); if (this.inTxn) { this.backupData = null; if (this.IsDirty) { if (this.bindingIsNew) { this.EntityState = EntityState.Added; this.bindingIsNew = false; } else if (this.EntityState == EntityState.Unchanged) { this.EntityState = EntityState.Changed; } } this.bindingIsNew = false; this.inTxn = false; } //Console.WriteLine("End EndEdit"); }
///<summary> /// Creates a new <see cref="MotoreBase"/> instance. ///</summary> ///<param name="_descrizione"></param> ///<param name="_aggregationMotoreID"></param> public MotoreBase(System.String _descrizione, System.Int32?_aggregationMotoreID) { this.entityData = new MotoreEntityData(); this.backupData = null; this.Descrizione = _descrizione; this.AggregationMotoreID = _aggregationMotoreID; }
/// <summary> /// Accepts the changes made to this object. /// </summary> /// <remarks> /// After calling this method, properties: IsDirty, IsNew are false. IsDeleted flag remains unchanged as it is handled by the parent List. /// </remarks> public override void AcceptChanges() { base.AcceptChanges(); // we keep of the original version of the data this._originalData = null; this._originalData = this.entityData.Clone() as MotoreEntityData; }
/// <summary> /// Begins an edit on an object. /// </summary> void IEditableObject.BeginEdit() { //Console.WriteLine("Start BeginEdit"); if (!inTxn) { this.backupData = this.entityData.Clone() as MotoreEntityData; inTxn = true; //Console.WriteLine("BeginEdit"); } //Console.WriteLine("End BeginEdit"); }
///<summary> /// Revert all changes and restore original values. ///</summary> public override void CancelChanges() { IEditableObject obj = (IEditableObject)this; obj.CancelEdit(); this.entityData = null; if (this._originalData != null) { this.entityData = this._originalData.Clone() as MotoreEntityData; } }
/// <summary> /// Discards changes since the last <c>BeginEdit</c> call. /// </summary> void IEditableObject.CancelEdit() { //Console.WriteLine("Start CancelEdit"); if (this.inTxn) { this.entityData = this.backupData; this.backupData = null; this.inTxn = false; if (this.bindingIsNew) //if (this.EntityState == EntityState.Added) { if (this.parentCollection != null) { this.parentCollection.Remove((Motore)this); } } } //Console.WriteLine("End CancelEdit"); }
/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns>A new object that is a copy of this instance.</returns> public object Clone(IDictionary existingCopies) { if (existingCopies == null) { existingCopies = new Hashtable(); } MotoreEntityData _tmp = new MotoreEntityData(); _tmp.ID = this.ID; _tmp.Descrizione = this.Descrizione; _tmp.AggregationMotoreID = this.AggregationMotoreID; #region Source Parent Composite Entities if (this.AggregationMotoreIDSource != null && existingCopies.Contains(this.AggregationMotoreIDSource)) { _tmp.AggregationMotoreIDSource = existingCopies[this.AggregationMotoreIDSource] as Motore; } else { _tmp.AggregationMotoreIDSource = MakeCopyOf(this.AggregationMotoreIDSource, existingCopies) as Motore; } #endregion #region Child Collections //deep copy nested objects _tmp.MotoreCollection = (TList <Motore>)MakeCopyOf(this.MotoreCollection, existingCopies); _tmp.PistoneCollection = (TList <Pistone>)MakeCopyOf(this.PistoneCollection, existingCopies); _tmp.Macchina = (Macchina)MakeCopyOf(this.Macchina, existingCopies); #endregion Child Collections //EntityState _tmp.EntityState = this.EntityState; return(_tmp); }
/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns>A new object that is a copy of this instance.</returns> public Object Clone() { MotoreEntityData _tmp = new MotoreEntityData(); _tmp.ID = this.ID; _tmp.Descrizione = this.Descrizione; _tmp.AggregationMotoreID = this.AggregationMotoreID; #region Source Parent Composite Entities if (this.AggregationMotoreIDSource != null) { _tmp.AggregationMotoreIDSource = MakeCopyOf(this.AggregationMotoreIDSource) as Motore; } #endregion #region Child Collections //deep copy nested objects if (this._motoreAggregationMotoreID != null) { _tmp.MotoreCollection = (TList <Motore>)MakeCopyOf(this.MotoreCollection); } if (this._pistoneCompositionMotoreID != null) { _tmp.PistoneCollection = (TList <Pistone>)MakeCopyOf(this.PistoneCollection); } if (this._macchinaAssociationMotoreID != null) { _tmp.Macchina = (Macchina)MakeCopyOf(this.Macchina); } #endregion Child Collections //EntityState _tmp.EntityState = this.EntityState; return(_tmp); }
///<summary> /// Creates a new <see cref="MotoreBase"/> instance. ///</summary> public MotoreBase() { this.entityData = new MotoreEntityData(); this.backupData = null; }