nHydrate.Generator.Models.CustomAggregateColumnController.DeleteObject C# (CSharp) Method

DeleteObject() public method

public DeleteObject ( ) : bool
return bool
		public override bool DeleteObject()
		{
			try
			{
				if (MessageBox.Show("Do you wish to delete the selected aggregate column?", "Delete?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
					return false;

				var parentNode = (ModelObjectTreeNode)this.Node.Parent;
				var referenceCollection = (ReferenceCollection)parentNode.Object;
				var customAggregatewColumnCollection = ((ModelRoot)this.Object.Root).Database.CustomAggregateColumns;

				foreach(Reference reference in referenceCollection)
				{
					if(reference.Object == this.Object)
					{
						parentNode.Controller.Refresh();
						customAggregatewColumnCollection.Remove((CustomAggregateColumn)reference.Object);
						referenceCollection.Remove(reference);
						break;
					}
				}

				this.Node.Remove();
				this.Object.Root.Dirty = true;
				return true;
			}
			catch(Exception ex)
			{
				throw;
			}

		}