System.Runtime.Remoting.MetadataServices.SdlParser.ParseElementField C# (CSharp) Method

ParseElementField() private method

private ParseElementField ( URTNamespace parsingNamespace, URTComplexType parsingComplexType, int fieldNum ) : void
parsingNamespace URTNamespace
parsingComplexType URTComplexType
fieldNum int
return void
        private void ParseElementField(URTNamespace parsingNamespace,
                                       URTComplexType parsingComplexType,
                                       int fieldNum)
        {
            Util.Log("SdlParser.ParseElementField NS "+parsingNamespace+" fieldNum "+fieldNum);         
            // Determine the field name
            String fieldTypeName, fieldTypeXmlNS;
            String fieldName = LookupAttribute(s_nameString, null, true);

            // Look for array bounds
            String minOccurs = LookupAttribute(s_minOccursString, null, false);
            String maxOccurs = LookupAttribute(s_maxOccursString, null, false);

            // Check if the field is optional
            bool bOptional = false;
            if(MatchingStrings(minOccurs, s_zeroString))
                bOptional = true;

            // Check if the field is an inline array
            bool bArray = false;
            String arraySize = null;
            if(!MatchingStrings(maxOccurs, s_emptyString) &&
               !MatchingStrings(maxOccurs, s_oneString))
            {
                if(MatchingStrings(maxOccurs, s_unboundedString))
                    arraySize = String.Empty;
                else
                    arraySize = maxOccurs;
                bArray = true;
            }

            // Handle anonymous types
            bool bEmbedded, bPrimitive;
            if(_XMLReader.IsEmptyElement == true)
            {
                // Non-anonymous type case
                fieldTypeName = LookupAttribute(s_typeString, null, false);

                // Handle the absense of type attribute (Object case)
                ResolveTypeAttribute(ref fieldTypeName, out fieldTypeXmlNS,
                                     out bEmbedded, out bPrimitive);

                // Read next element
                ReadNextXmlElement();
            }
            else
            {
                // Anonymous type case
                fieldTypeXmlNS = parsingNamespace.Namespace;
                fieldTypeName = parsingNamespace.GetNextAnonymousName();
                bPrimitive = false;
                bEmbedded = true;
                int curDepth = _XMLReader.Depth;
                ReadNextXmlElement();

                // Parse the type
                String elementName;
                while(_XMLReader.Depth > curDepth)
                {
                    elementName = _XMLReader.LocalName;
                    if(MatchingStrings(elementName, s_complexTypeString))
                    {
                        URTComplexType complexType = ParseComplexType(parsingNamespace, fieldTypeName);
                        if(complexType.IsEmittableFieldType)
                        {
                            fieldTypeXmlNS = complexType.FieldNamespace;
                            fieldTypeName = complexType.FieldName;
                            bPrimitive = complexType.PrimitiveField;
                            parsingNamespace.RemoveComplexType(complexType);
                        }
                    }
                    else if(MatchingStrings(elementName, s_simpleTypeString))
                    {
                        URTSimpleType simpleType = ParseSimpleType(parsingNamespace, fieldTypeName);
                        if(simpleType.IsEmittableFieldType)
                        {
                            fieldTypeXmlNS = simpleType.FieldNamespace;
                            fieldTypeName = simpleType.FieldName;
                            bPrimitive = simpleType.PrimitiveField;
                            parsingNamespace.RemoveSimpleType(simpleType);
                        }
                    }
                    else
                    {
                        // Ignore others elements such as annotations
                        SkipXmlElement();
                    }
                }
            }

            // Add field to the type being parsed
            parsingComplexType.AddField(new URTField(fieldName, fieldTypeName, fieldTypeXmlNS,
                                                     this, bPrimitive, bEmbedded, false,
                                                     bOptional, bArray, arraySize));
            return;
        }