protected bool Add(AObject aObject)
{
bool result = false;
if (aObject != null)
{
lock (_children)
{
if (!DuplicateChildExists(aObject))
{
Activate(ActivationPurpose.Write);
_children.Add(aObject);
result = true;
}
}
if (result)
{
aObject.Parent = this;
aObject.OnEnabledChanged += FireEnabledChanged;
aObject.OnChanged += FireChanged;
var aObjects = aObject as AObjects;
if (aObjects != null)
{
aObjects.OnAdded += FireAdded;
aObjects.OnRemoved += FireRemoved;
}
FireAdded(this, new EventArgs<AObject, AObject>(this, aObject));
}
}
return result;
}