private static int GetOptionalFieldIntValueSize(string value)
{
uint positiveValue;
int negativeValue;
if (!uint.TryParse(value, out positiveValue))
{
if (!int.TryParse(value, out negativeValue))
{
return 0;
}
if (sbyte.MinValue <= negativeValue)
{
return -1;
}
if (short.MinValue <= negativeValue)
{
return -2;
}
return -4;
}
if (byte.MaxValue >= positiveValue)
{
return 1;
}
if (ushort.MaxValue >= positiveValue)
{
return 2;
}
return 4;
}