Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ReadEnumeratedValue()

static Enum System.Formats.Asn1.AsnDecoder.ReadEnumeratedValue ( ReadOnlySpan< byte > source,
AsnEncodingRules ruleSet,
Type enumType,
out int bytesConsumed,
Asn1Tag? expectedTag = null )
inlinestatic

Definition at line 693 of file AsnDecoder.cs.

694 {
695 if (enumType == null)
696 {
697 throw new ArgumentNullException("enumType");
698 }
699 Asn1Tag expectedTag2 = expectedTag ?? Asn1Tag.Enumerated;
700 Type enumUnderlyingType = enumType.GetEnumUnderlyingType();
701 if (enumType.IsDefined(typeof(FlagsAttribute), inherit: false))
702 {
704 }
707 {
709 {
710 throw new AsnContentException(System.SR.ContentException_EnumeratedValueTooBig);
711 }
713 return (Enum)Enum.ToObject(enumType, value);
714 }
715 if (enumUnderlyingType == typeof(uint) || enumUnderlyingType == typeof(ulong) || enumUnderlyingType == typeof(ushort) || enumUnderlyingType == typeof(byte))
716 {
718 {
719 throw new AsnContentException(System.SR.ContentException_EnumeratedValueTooBig);
720 }
722 return (Enum)Enum.ToObject(enumType, value2);
723 }
725 }
static bool TryReadUnsignedInteger(ReadOnlySpan< byte > source, AsnEncodingRules ruleSet, int sizeLimit, Asn1Tag expectedTag, UniversalTagNumber tagNumber, out ulong value, out int bytesConsumed)
static bool TryReadSignedInteger(ReadOnlySpan< byte > source, AsnEncodingRules ruleSet, int sizeLimit, Asn1Tag expectedTag, UniversalTagNumber tagNumber, out long value, out int bytesConsumed)
static int SizeOf(object structure)
Definition Marshal.cs:697
static string ContentException_EnumeratedValueTooBig
Definition SR.cs:52
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Argument_EnumeratedValueRequiresNonFlagsEnum
Definition SR.cs:16
static string Argument_EnumeratedValueBackingTypeNotSupported
Definition SR.cs:18
Definition SR.cs:7

References System.SR.Argument_EnumeratedValueBackingTypeNotSupported, System.SR.Argument_EnumeratedValueRequiresNonFlagsEnum, System.SR.ContentException_EnumeratedValueTooBig, System.Formats.Asn1.Asn1Tag.Enumerated, System.SR.Format(), System.Runtime.InteropServices.Marshal.SizeOf(), System.source, System.Enum.ToObject(), System.Formats.Asn1.AsnDecoder.TryReadSignedInteger(), System.Formats.Asn1.AsnDecoder.TryReadUnsignedInteger(), and System.value.

Referenced by System.Formats.Asn1.AsnReader.ReadEnumeratedValue(), System.Formats.Asn1.AsnReader.ReadEnumeratedValue< TEnum >(), and System.Formats.Asn1.AsnDecoder.ReadEnumeratedValue< TEnum >().