in sdk/src/Core/Internal/Entities/Entity.cs [440:484]
public void AddAnnotation(string key, object value)
{
if (string.IsNullOrEmpty(key))
{
throw new ArgumentException("Key cannot be null or empty", nameof(key));
}
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
if (value is int)
{
_lazyAnnotations.Value.Add(key, (int)value);
return;
}
if (value is long)
{
_lazyAnnotations.Value.Add(key, (long)value);
return;
}
string stringValue = value as string;
if (stringValue != null)
{
_lazyAnnotations.Value.Add(key, stringValue);
return;
}
if (value is double)
{
_lazyAnnotations.Value.Add(key, (double)value);
return;
}
if (value is bool)
{
_lazyAnnotations.Value.Add(key, (bool)value);
return;
}
throw new InvalidAnnotationException(string.Format(CultureInfo.InvariantCulture, "Failed to add key={0}, value={1}, valueType={2} because the type is not supported.", key, value.ToString(), value.GetType().ToString()));
}