System.Xml.Serialization.XmlSchemaImporter.ImportEnumeratedChoice C# (CSharp) Method

ImportEnumeratedChoice() private method

private ImportEnumeratedChoice ( ElementAccessor choice, string typeNs, string typeName ) : EnumMapping
choice ElementAccessor
typeNs string
typeName string
return EnumMapping
        private EnumMapping ImportEnumeratedChoice(ElementAccessor[] choice, string typeNs, string typeName)
        {
            typeName = GenerateUniqueTypeName(Accessor.UnescapeName(typeName), typeNs);
            EnumMapping enumMapping = new EnumMapping();
            enumMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Enum, null, 0);
            enumMapping.TypeName = typeName;
            enumMapping.Namespace = typeNs;
            enumMapping.IsFlags = false;
            enumMapping.IncludeInSchema = false;

            if (GenerateOrder)
            {
                Array.Sort(choice, new ElementComparer());
            }
            CodeIdentifiers constants = new CodeIdentifiers();
            for (int i = 0; i < choice.Length; i++)
            {
                ElementAccessor element = choice[i];
                ConstantMapping constant = new ConstantMapping();
                string constantName = CodeIdentifier.MakeValid(element.Name);
                constant.Name = constants.AddUnique(constantName, constant);
                constant.XmlName = element.ToString(typeNs);
                constant.Value = i;
            }
            enumMapping.Constants = (ConstantMapping[])constants.ToArray(typeof(ConstantMapping));
            Scope.AddTypeMapping(enumMapping);
            return enumMapping;
        }