Lines Matching defs:text
693 private static object ParseSingleStringValue(FieldDescriptor field, string text)
698 return text;
702 return ByteString.FromBase64(text);
711 return ParseNumericString(text, int.Parse);
714 return ParseNumericString(text, uint.Parse);
718 return ParseNumericString(text, long.Parse);
721 return ParseNumericString(text, ulong.Parse);
723 double d = ParseNumericString(text, double.Parse);
724 ValidateInfinityAndNan(text, double.IsPositiveInfinity(d), double.IsNegativeInfinity(d), double.IsNaN(d));
727 float f = ParseNumericString(text, float.Parse);
728 ValidateInfinityAndNan(text, float.IsPositiveInfinity(f), float.IsNegativeInfinity(f), float.IsNaN(f));
731 var enumValue = field.EnumType.FindValueByName(text);
734 throw new InvalidProtocolBufferException($"Invalid enum value: {text} for enum type: {field.EnumType.FullName}");
751 private static T ParseNumericString<T>(string text, Func<string, NumberStyles, IFormatProvider, T> parser)
754 if (text.StartsWith("+"))
756 throw new InvalidProtocolBufferException($"Invalid numeric value: {text}");
758 if (text.StartsWith("0") && text.Length > 1)
760 if (text[1] >= '0' && text[1] <= '9')
762 throw new InvalidProtocolBufferException($"Invalid numeric value: {text}");
765 else if (text.StartsWith("-0") && text.Length > 2)
767 if (text[2] >= '0' && text[2] <= '9')
769 throw new InvalidProtocolBufferException($"Invalid numeric value: {text}");
774 return parser(text, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent, CultureInfo.InvariantCulture);
778 throw new InvalidProtocolBufferException($"Invalid numeric value for type: {text}");
782 throw new InvalidProtocolBufferException($"Value out of range: {text}");
787 /// Checks that any infinite/NaN values originated from the correct text.
791 private static void ValidateInfinityAndNan(string text, bool isPositiveInfinity, bool isNegativeInfinity, bool isNaN)
793 if ((isPositiveInfinity && text != "Infinity") ||
794 (isNegativeInfinity && text != "-Infinity") ||
795 (isNaN && text != "NaN"))
797 throw new InvalidProtocolBufferException($"Invalid numeric value: {text}");
937 private static string ToSnakeCase(string text)
939 var builder = new StringBuilder(text.Length * 2);
945 for (int i = 0; i < text.Length; i++)
947 char c = text[i];
961 (i + 1 < text.Length && // case 3 out
962 (text[i + 1] >= 'a' && text[i + 1] <= 'z')))) // ascii_islower(text[i + 1])
977 throw new InvalidProtocolBufferException($"Invalid field mask: {text}");