public virtual void SetProperty(IContextProperty prop)
{
// We do not let people add properties to the default context.
/* We allow appdomain level properties to be added to the default context
if ((_ctxFlags & CTX_DEFAULT_CONTEXT) != 0)
{
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AddContextFrozen"));
}
*/
if (prop == null || prop.Name == null)
{
throw new ArgumentNullException((prop==null) ? "prop" : "property name");
}
if ((_ctxFlags & CTX_FROZEN) != 0)
{
throw new InvalidOperationException(
Environment.GetResourceString("InvalidOperation_AddContextFrozen"));
}
lock (this)
{
// Check if we have a property by this name
CheckPropertyNameClash(prop.Name, _ctxProps, _numCtxProps);
// check if we need to grow the array.
if (_ctxProps == null || _numCtxProps == _ctxProps.Length)
{
_ctxProps = GrowPropertiesArray(_ctxProps);
}
// now add the property
_ctxProps[_numCtxProps++] = prop;
}
}