internal virtual bool AddDynamicProperty(IDynamicProperty prop)
{
lock(this) {
// We have to add a sink specific to the given context
CheckPropertyNameClash(prop.Name, _props, _numProps);
// check if we need to grow the array.
bool bGrow=false;
if (_props == null || _numProps == _props.Length)
{
_props = GrowPropertiesArray(_props);
bGrow = true;
}
// now add the property
_props[_numProps++] = prop;
// we need to grow the sinks if we grew the props array or we had thrown
// away the sinks array due to a recent removal!
if (bGrow)
{
_sinks = GrowDynamicSinksArray(_sinks);
}
if (_sinks == null)
{
// Some property got unregistered -- we need to recreate
// the list of sinks.
_sinks = new IDynamicMessageSink[_props.Length];
for (int i=0; i<_numProps; i++)
{
_sinks[i] =
((IContributeDynamicSink)_props[i]).GetDynamicSink();
}
}
else
{
// append the Sink to the existing array of Sinks
_sinks[_numProps-1] =
((IContributeDynamicSink)prop).GetDynamicSink();
}
return true;
}
}