, AddOrUpdate, TryUpdate.
, . , , , , . :
public TValue AddOrUpdate(TKey key, Func<TKey, TValue> addValueFactory, Func<TKey, TValue, TValue> updateValueFactory)
{
TValue local;
TValue local3;
if (key == null)
{
throw new ArgumentNullException("key");
}
if (addValueFactory == null)
{
throw new ArgumentNullException("addValueFactory");
}
if (updateValueFactory == null)
{
throw new ArgumentNullException("updateValueFactory");
}
do
{
if (!this.TryGetValue(key, out local3))
{
TValue local2;
local = addValueFactory(key);
if (!this.TryAddInternal(key, local, false, true, out local2))
{
continue;
}
return local2;
}
local = updateValueFactory(key, local3);
}
while (!this.TryUpdate(key, local, local3));
return local;
}
, factory , , . factory. ?