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

◆ FindChoiceEnumValue()

string System.Xml.Serialization.XmlSerializationWriterILGen.FindChoiceEnumValue ( ElementAccessor element,
EnumMapping choiceMapping,
out object eValue )
inlineprivate

Definition at line 1952 of file XmlSerializationWriterILGen.cs.

1953 {
1954 string text = null;
1955 eValue = null;
1956 for (int i = 0; i < choiceMapping.Constants.Length; i++)
1957 {
1958 string xmlName = choiceMapping.Constants[i].XmlName;
1959 if (element.Any && element.Name.Length == 0)
1960 {
1961 if (xmlName == "##any:")
1962 {
1963 text = choiceMapping.Constants[i].Name;
1964 eValue = Enum.ToObject(choiceMapping.TypeDesc.Type, choiceMapping.Constants[i].Value);
1965 break;
1966 }
1967 continue;
1968 }
1969 int num = xmlName.LastIndexOf(':');
1970 string text2 = ((num < 0) ? choiceMapping.Namespace : xmlName.Substring(0, num));
1971 string text3 = ((num < 0) ? xmlName : xmlName.Substring(num + 1));
1972 if (element.Name == text3 && ((element.Form == XmlSchemaForm.Unqualified && string.IsNullOrEmpty(text2)) || element.Namespace == text2))
1973 {
1974 text = choiceMapping.Constants[i].Name;
1975 eValue = Enum.ToObject(choiceMapping.TypeDesc.Type, choiceMapping.Constants[i].Value);
1976 break;
1977 }
1978 }
1979 if (text == null || text.Length == 0)
1980 {
1981 if (element.Any && element.Name.Length == 0)
1982 {
1984 }
1985 throw new InvalidOperationException(System.SR.Format(System.SR.XmlChoiceMissingValue, choiceMapping.TypeDesc.FullName, element.Namespace + ":" + element.Name, element.Name, element.Namespace));
1986 }
1987 CodeIdentifier.CheckValidIdentifier(text);
1988 return text;
1989 }
static string XmlChoiceMissingAnyValue
Definition SR.cs:1656
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlChoiceMissingValue
Definition SR.cs:1654
Definition SR.cs:7

References System.Xml.Serialization.Accessor.Any, System.Xml.Serialization.CodeIdentifier.CheckValidIdentifier(), System.Xml.Serialization.Accessor.Form, System.SR.Format(), System.Xml.Serialization.Accessor.Name, System.Xml.Serialization.Accessor.Namespace, System.text, System.Enum.ToObject(), System.SR.XmlChoiceMissingAnyValue, and System.SR.XmlChoiceMissingValue.

Referenced by System.Xml.Serialization.XmlSerializationWriterILGen.WriteElements().