namespace Autozite.Entities
{
public delegate void DimensionInsideChangeEventHandler(Dimension sender, xEventArgs<int> e);
public class Dimension
{
private int _Id;
public int Id
{
get { return _Id; }
set { _Id = value; OnChange(new xEventArgs<int>(_Size)); }
}
private int _Size;
public int Size
{
get { return _Size; }
set { _Size = value; OnChange(new xEventArgs<int>(_Size)); }
}
#region Event On Method
public event DimensionInsideChangeEventHandler DimensionChange;
protected virtual void OnChange(xEventArgs<int> e)
{
DimensionInsideChangeEventHandler handler = DimensionChange;
if (handler != null)
{
handler(this, e);
}
}
#endregion
}
}
namespace Autozite.Entities
{
//Change
public delegate void DimensionAddadEventHandler(Dimensions sender, xEventArgs<Dimension> e);
public delegate void DimensionRemovedEventHandler(Dimensions sender, xEventArgs<Dimension> e);
public delegate void DimensionChangeEventHandler(Dimensions sender, xEventArgs<Dimension> e);
public class Dimensions : List<Dimension>
{
public Dimensions()
{
}
private void Dimensions_DimensionChange(Dimension sender, xEventArgs<int> e)
{
throw new NotImplementedException();
}
public event DimensionAddadEventHandler DimensionAddad;
public event DimensionRemovedEventHandler DimensionRemoved;
public event DimensionChangeEventHandler DimensionChange;
public new void Add(Dimension dimension)
{
base.Add(dimension);
OnAdded(new xEventArgs<Dimension>(dimension));
OnChange(new xEventArgs<Dimension>(dimension));
}
public new void Remove(Dimension dimension)
{
base.Remove(dimension);
OnRemoved(new xEventArgs<Dimension>(dimension));
OnChange(new xEventArgs<Dimension>(dimension));
}
#region Event On Method
protected virtual void OnAdded(xEventArgs<Dimension> e)
{
DimensionAddadEventHandler handler = DimensionAddad;
if (handler != null)
{
handler(this, e);
}
}
protected virtual void OnRemoved(xEventArgs<Dimension> e)
{
DimensionAddadEventHandler handler = DimensionAddad;
if (handler != null)
{
handler(this, e);
}
}
protected virtual void OnChange(xEventArgs<Dimension> e)
{
DimensionChangeEventHandler handler = DimensionChange;
if (handler != null)
{
handler(this, e);
}
}
#endregion
}
}
I am trying to control the changes of Dimension object inside Dimensions class derived from List<>
with event. but I couldn't write more.