コード例 #1
0
        void AddElementsToContainer(wsdlParser.qname xmlName, MSXML2.ISchemaModelGroup smg, ComplexTypeWriter ctw, SerializerWriter sw)
        {
            foreach (MSXML2.ISchemaParticle particle in smg.particles)
            {
                if ((particle.itemType == MSXML2.SOMITEMTYPE.SOMITEM_ALL) || (particle.itemType == MSXML2.SOMITEMTYPE.SOMITEM_SEQUENCE))
                {
                    AddElementsToContainer(xmlName, particle as MSXML2.ISchemaModelGroup, ctw, sw);
                }
                else if (particle.itemType == MSXML2.SOMITEMTYPE.SOMITEM_ELEMENT)
                {
                    MSXML2.ISchemaElement e = (MSXML2.ISchemaElement)particle;
                    CppType itemType        = CppType.FromParticle(this, particle);
                    string  itemName        = vcProject.safeClassName(particle.name);

                    ctw.AddPropertyField(itemName, itemType);
                    sw.AddElement(itemName, itemType, e);
                }
            }
        }
コード例 #2
0
        CppType CreateComplexType(wsdlParser.qname typeName, MSXML2.ISchemaComplexType typeDesc)
        {
            // look to see if its a section 5 encoded array first
            foreach (MSXML2.ISchemaType bt in typeDesc.baseTypes)
            {
                if ((bt.name == "Array") && (bt.namespaceURI == Consts.SOAP_11_ENCODING))
                {
                    return(HandleArrayType(typeName, typeDesc));
                }
            }

            CppType t = CppType.Create((int)VarEnum.VT_UNKNOWN, NameBuilder(typeName), CppType.ArrayType.NotArray, CppType.TypeStyle.Object, false, typeName);

            // a qname for the serializer class
            wsdlParser.qname tSerQName = new wsdlParser.qnameClass();
            tSerQName.localname  = "s" + typeName.localname;
            tSerQName.@namespace = "http://serializers.schemas.pocketsoap.com/";

            // register the type mapping now, incase there is some recursive nonsense going on
            m_typesCache[typeName.ExpandedName] = t;

            // a complexTypeWriter
            ComplexTypeWriter ctw = new ComplexTypeWriter(m_project, typeName.ExpandedName, t.CppName);

            // a SerializerWriter
            SerializerWriter sw = new SerializerWriter(m_project, tSerQName, NameBuilder(tSerQName), t.CppName);

            MSXML2.ISchemaComplexType complexType = typeDesc;
            MSXML2.ISchemaModelGroup  smg         = complexType.contentModel;

            // walk through each contained particle

            // attributes
            foreach (MSXML2.ISchemaAttribute attr in complexType.attributes)
            {
                wsdlParser.qname ptype = new wsdlParser.qnameClass();
                ptype.@namespace = attr.type.namespaceURI;
                ptype.localname  = attr.type.name;
                CppType itemType = mapType(ptype);
                string  itemName = vcProject.safeClassName(attr.name);
                ctw.AddPropertyField(itemName, itemType);
                sw.AddAttribute(itemName, itemType, attr, ptype);
            }

            AddElementsToContainer(typeName, smg, ctw, sw);

            ctw.Complete();
            sw.Complete();

            // add type registrations
            string serProgId = m_project.ProjectName + "." + sw.SerializerName;
            string clsProgId = m_project.ProjectName + "." + ctw.ComplexTypeName;
            string clsItfIID = string.Format("CComVariant(OLESTR(\"{{{0}}}\"))", ctw.InterfaceIID);

            m_factory.Add(string.Format("m_sf->Serializer({0}, CComBSTR(OLESTR(\"{1}\")), CComBSTR(OLESTR(\"{2}\")), CComBSTR(OLESTR(\"{3}\")));", clsItfIID, typeDesc.name, typeDesc.namespaceURI, serProgId));

            string typeLN = string.Format("CComBSTR(OLESTR(\"{0}\"))", typeName.localname);
            string typeNS = string.Format("CComBSTR(OLESTR(\"{0}\"))", typeName.@namespace);

            m_factory.Add(string.Format("m_sf->Deserializer({0}, {1}, VARIANT_FALSE, CComVariant(OLESTR(\"{2}\")), {3});", typeLN, typeNS, clsProgId, makeBstr(serProgId)));
            return(t);
        }