System.Xml.Serialization.XmlReflectionImporter.CheckChoiceIdentifierMapping C# (CSharp) Method

CheckChoiceIdentifierMapping() private method

private CheckChoiceIdentifierMapping ( EnumMapping choiceMapping ) : void
choiceMapping EnumMapping
return void
        private void CheckChoiceIdentifierMapping(EnumMapping choiceMapping)
        {
            NameTable ids = new NameTable();
            for (int i = 0; i < choiceMapping.Constants.Length; i++)
            {
                string choiceId = choiceMapping.Constants[i].XmlName;
                int colon = choiceId.LastIndexOf(':');
                string choiceName = colon < 0 ? choiceId : choiceId.Substring(colon + 1);
                string choiceNs = colon < 0 ? "" : choiceId.Substring(0, colon);

                if (ids[choiceName, choiceNs] != null)
                {
                    // Enum values in the XmlChoiceIdentifier '{0}' have to be unique.  Value '{1}' already present.
                    throw new InvalidOperationException(SR.Format(SR.XmlChoiceIdDuplicate, choiceMapping.TypeName, choiceId));
                }
                ids.Add(choiceName, choiceNs, choiceMapping.Constants[i]);
            }
        }