internal CppType mapType(wsdlParser.qname type)
        {
            if (m_sf.IsAnyType(type.localname, type.@namespace))
            {
                return(CppType.Create((int)VarEnum.VT_VARIANT, "VARIANT", CppType.ArrayType.NotArray, CppType.TypeStyle.Primative, false, type));
            }
            CppType t = null;

            try
            {
                Object ct = m_sf.FindComType(type.localname, type.@namespace);
                if (ct is int)
                {
                    return(CppType.TypeFromVariantType((int)ct, type));
                }
                return(CppType.Create((int)VarEnum.VT_VARIANT, "VARIANT", type));
            }
            catch (Exception ex)
            {
                // todo, catch specific exception
                // todo, handle complex types.
                // Console.WriteLine(type.ExpandedName + " : " + ex.Message);
            }
            // handle non-primitive types

            // first off, check the cache
            t = (CppType)m_typesCache[type.ExpandedName];
            if (t != null)
            {
                return(t);
            }

            // look for a schema definition
            MSXML2.ISchema     schema = SchemaForType(type);
            MSXML2.ISchemaType oType  = (MSXML2.ISchemaType)schema.types.itemByQName(type.localname, type.@namespace);
            if (oType is MSXML2.ISchemaComplexType)
            {
                t = CreateComplexType(type, (MSXML2.ISchemaComplexType)oType);
            }
            else if (oType.enumeration.length > 0)
            {
                t = CreateEnumType(type, oType);
            }
            else if ((oType.itemType == MSXML2.SOMITEMTYPE.SOMITEM_SIMPLETYPE) && (oType.derivedBy == MSXML2.SCHEMADERIVATIONMETHOD.SCHEMADERIVATIONMETHOD_RESTRICTION))
            {
                t = CreateRestrictedSimpleType(type, oType);
            }
            else
            {
                throw new ApplicationException("Sorry, this type " + type.ExpandedName + " is not yet supported");
            }
            return(t);
        }
Beispiel #2
0
        void GenerateOptionalAccessor(string propertyName)
        {
            CppType variant_bool = CppType.Create("VARIANT_BOOL");

            GeneratePropertyAccessor(propertyName + Consts.OPTIONAL_PROPERTY_SUFFIX, OPT_PREFIX + propertyName, "", variant_bool);
        }
 private CppType genDocLiteralType(wsdlParser.qname elementName)
 {
     // todo
     return(CppType.Create("VARIANT"));
 }
        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);
        }