// Parses a class
        private void ParseClass(URTNamespace parsingNamespace)
        {
            Util.Log("SdlParser.ParseClass");
            String className = LookupAttribute(s_nameString, null, false);
            bool bUnique = false;
            if((className == s_emptyString) && (_parsingInput.UniqueType == null))
            {
                className = _parsingInput.Name;
                bUnique = true;
            }
            URTComplexType parsingComplexType = parsingNamespace.LookupComplexType(className);
            if(parsingComplexType == null)
            {
                parsingComplexType = new URTComplexType(className, parsingNamespace.Namespace,
                                                        parsingNamespace.EncodedNS, _blockDefault,
                                                        true, false);
                if(_bWrappedProxy)
                {
                    parsingComplexType.SUDSType = SUDSType.ClientProxy;

                    if (_parsingInput.Location.Length > 0)
                    {
                        if (parsingComplexType.ConnectURLs == null)
                            parsingComplexType.ConnectURLs = new ArrayList(10);
                        parsingComplexType.ConnectURLs.Add(_parsingInput.Location);
                    }
                }
                
                parsingNamespace.AddComplexType(parsingComplexType);
            }
            if(bUnique)
            {
                _parsingInput.UniqueType = parsingComplexType;
            }
            if(parsingComplexType.Methods.Count > 0)
            {
                SkipXmlElement();
            }
            else
            {
                parsingComplexType.IsSUDSType = true;
                int curDepth = _XMLReader.Depth;
                ReadNextXmlElement();
                while(_XMLReader.Depth > curDepth)
                {
                    if(MatchingNamespace(s_sudsNamespaceString))
                    {
                        String elmName = _XMLReader.LocalName;
                        if(MatchingStrings(elmName, s_extendsString))
                        {
                            String nameValue = LookupAttribute(s_nameString, null, true);
                            String nameValueNS = ParseQName(ref nameValue);
                            parsingComplexType.Extends(nameValue, nameValueNS);

                            //Set up extend class so that it is marked as the correct SUDSType
                            URTNamespace extendsNamespace = LookupNamespace(nameValueNS);                   
                            if (extendsNamespace == null)
                                extendsNamespace = new URTNamespace(nameValueNS, this);                     

                            URTComplexType extendsComplexType = extendsNamespace.LookupComplexType(nameValue);                  
                            if(extendsComplexType == null)
                            {
                                extendsComplexType = new URTComplexType(nameValue, extendsNamespace.Namespace, extendsNamespace.EncodedNS, _blockDefault ,true, false);
                                extendsNamespace.AddComplexType(extendsComplexType);
                            }
                            else
                                extendsComplexType.IsSUDSType = true;

                            if (_bWrappedProxy)
                                extendsComplexType.SUDSType = SUDSType.ClientProxy;
                            else
                                extendsComplexType.SUDSType = SUDSType.MarshalByRef;

                            // Only top of inheritance hierarchy is marked
                            //parsingComplexType.SUDSType = SUDSType.None;  

                        }
                        else if(MatchingStrings(elmName, s_implementsString))
                        {
                            String nameValue = LookupAttribute(s_nameString, null, true);
                            String nameValueNS = ParseQName(ref nameValue);
                            parsingComplexType.Implements(nameValue, nameValueNS, this);
                        }
                        else if(MatchingStrings(elmName, s_addressesString))
                        {
                            ParseAddresses(parsingComplexType);
                            continue;
                        }
                        else if(MatchingStrings(elmName, s_requestResponseString))
                        {
                            ParseRRMethod(parsingComplexType, null);
                            continue;
                        }
                        else if(MatchingStrings(elmName, s_onewayString))
                        {
                            ParseOnewayMethod(parsingComplexType, null);
                            continue;
                        }
                        else
                            goto SkipXMLNode;
                    }
                    else
                        goto SkipXMLNode;

                    // Read next element
                    ReadNextXmlElement();
                    continue;

        SkipXMLNode:
                    // Ignore others elements such as annotations
                    SkipXmlElement();
                }
            }

            return;
        }
Example #2
0
            internal URTComplexType(String name, String urlNS, String ns, String encodedNS,
                                    SchemaBlockType blockDefault, bool bSUDSType, bool bAnonymous, WsdlParser parser, URTNamespace xns)
            : base(name, urlNS, ns, encodedNS)
            {
                Util.Log("URTComplexType.URTComplexType name "+this.GetHashCode()+" "+name+" urlNS "+urlNS+" ns "+ns+" encodedNS "+encodedNS+" bSUDStype "+bSUDSType+" bAnonymous "+bAnonymous);
                _baseTypeName = null;
                _baseTypeXmlNS = null;
                _baseType = null;
                _connectURLs = null;
                _bStruct = !bSUDSType;
                _blockType = blockDefault;
                _bSUDSType = bSUDSType;
                _bAnonymous = bAnonymous;
                Debug.Assert(bAnonymous == false || _bSUDSType == false);
                _fieldString = null;
                _fields = new ArrayList();
                _methods = new ArrayList();
                _implIFaces = new ArrayList();
                _implIFaceNames = new ArrayList();
                _sudsType = SUDSType.None;              
                _parser = parser;

                int index = name.IndexOf('+');
                if (index > 0)
                {
                    // Nested type see if outer type has been added to namespace
                    String outerType = parser.Atomize(name.Substring(0,index));
                    URTComplexType cs = xns.LookupComplexType(outerType);
                    if (cs == null)
                    {
                        URTComplexType newCs = new URTComplexType(outerType, urlNS, ns, encodedNS, blockDefault, bSUDSType, bAnonymous, parser, xns);
                        Util.Log("URTComplexType.URTComplexType add outerType to namespace "+outerType+" nestedname "+name);
                        xns.AddComplexType(newCs);
                    }
                }


                if (xns.UrtType == UrtType.Interop)
                {
                    // Interop class names can have '.', replace these with '_', and set wire name to original type name.
                    index = name.LastIndexOf('.');
                    if (index > -1)
                    {
                        // class names can't have '.' so replace with '$'. Use xmlType attribute to send original name on wire.
                        _wireType = name;
                        Name = name.Replace(".", "_");
                        SearchName = name;
                    }
                }

            }
        // Parses complex types
        private URTComplexType ParseComplexType(URTNamespace parsingNamespace, String typeName)
        {
            Util.Log("SdlParser.ParseComplexType NS "+parsingNamespace+" typeName "+typeName);                                  
            // Lookup the name of the type and the base type from which it derives
            if(typeName == null)
                typeName = LookupAttribute(s_nameString, null, true);
            URTComplexType parsingComplexType = parsingNamespace.LookupComplexType(typeName);
            if(parsingComplexType == null)
            {
                parsingComplexType = new URTComplexType(typeName, parsingNamespace.Namespace,
                    parsingNamespace.EncodedNS, _blockDefault,
                    false, typeName != null);
                parsingNamespace.AddComplexType(parsingComplexType);
            }
            String baseType = LookupAttribute(s_baseString, null, false);
            if(!MatchingStrings(baseType, s_emptyString))
            {
                String baseNS = ParseQName(ref baseType);
                //if the type exists can this occur twice.
                parsingComplexType.Extends(baseType, baseNS);
            }

            if(parsingComplexType.Fields.Count > 0)
            {
                SkipXmlElement();
            }
            else
            {
                int curDepth = _XMLReader.Depth;
                ReadNextXmlElement();

                int fieldNum = 0;
                String elementName;
                while(_XMLReader.Depth > curDepth)
                {
                    elementName = _XMLReader.LocalName;
                    if(MatchingStrings(elementName, s_elementString))
                    {
                        ParseElementField(parsingNamespace, parsingComplexType, fieldNum);
                        ++fieldNum;
                        continue;
                    }
                    else if(MatchingStrings(elementName, s_attributeString))
                    {
                        ParseAttributeField(parsingNamespace, parsingComplexType);
                        continue;
                    }
                    else if(MatchingStrings(elementName, s_allString))
                    {
                        parsingComplexType.BlockType = SchemaBlockType.ALL;
                    }
                    else if(MatchingStrings(elementName, s_sequenceString))
                    {
                        parsingComplexType.BlockType = SchemaBlockType.SEQUENCE;
                    }
                    else if(MatchingStrings(elementName, s_choiceString))
                    {
                        parsingComplexType.BlockType = SchemaBlockType.CHOICE;
                    }
                    else
                    {
                        // Ignore others elements such as annotations
                        SkipXmlElement();
                        continue;
                    }

                    // Read next element
                    ReadNextXmlElement();
                }
            }

            return(parsingComplexType);
        }