public void SetPrivateExtension(string prefix, string data)
{
// Prefix cannot be null, it is the hashtable key
if (prefix == null)
{
throw new ArgumentNullException(Strings.Prefix);
}
byte[] prefixBytes;
lock (utf8)
{
prefixBytes = utf8.GetBytes(prefix);
}
// Data can be null though, if the prefix communicates enough data
byte[] dataBytes = null;
int dataLength = 0;
if (data != null)
{
lock (utf8)
{
dataBytes = utf8.GetBytes(data);
dataLength = dataBytes.Length;
}
}
// Check to see if it is too long
if (prefixBytes.Length + dataLength > MAX_PRIV_PROPERTY_LENGTH)
{
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.PrefixAndDataBytesExceeded,
MAX_PRIV_PROPERTY_LENGTH));
}
SetPrivateExtension(prefixBytes, dataBytes);
}