Esempio n. 1
0
        private void CreateArrayClass(SoapClasses arrClass)
        {
            try
            {
                string arraystr = FileHelper.GetManifestResourceStream("ArrayObjectTemplate");
                arraystr = arraystr.Replace("%%DATE%%", DateTime.Now.ToString()).Replace("%%PACKAGENAME%%", WebService.PackageName);
                arraystr = arraystr.Replace("%%NAMESPACE%%", WebService.NameSpace).Replace("%%CLASSNAME%%", arrClass.Name);
                arraystr = arraystr.Replace("%%ELEMENTTYPE%%", JavaTypeConverter.ToElementJavaType(arrClass.ElementType)).Replace("%%ELEMENTTYPEDESC%%", JavaTypeConverter.ArrayElementTypeDesc(arrClass.ElementType));

                StringBuilder loadstr = new StringBuilder();
                if (arrClass.ElementType == "char")
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) instanceof SoapPrimitive) {");
                    loadstr.AppendLine("                    SoapPrimitive pi = (SoapPrimitive) property.getProperty(loop);");
                    loadstr.AppendLine("                    int intchar = Integer.valueOf(pi.toString());");
                    loadstr.AppendLine("                    this.add((char) intchar);");
                    loadstr.AppendLine("                }");
                }
                else if (arrClass.ElementType == "Integer")
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) instanceof SoapPrimitive) {");
                    loadstr.AppendLine("                    SoapPrimitive pi = (SoapPrimitive) property.getProperty(loop);");
                    loadstr.AppendLine("                    Integer item = Integer.valueOf(pi.toString());");
                    loadstr.AppendLine("                    this.add(item);");
                    loadstr.AppendLine("                }");
                }
                else if (arrClass.ElementType == "String")
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) instanceof SoapPrimitive) {");
                    loadstr.AppendLine("                    SoapPrimitive pi = (SoapPrimitive) property.getProperty(loop);");
                    loadstr.AppendLine("                    String item = pi.toString();");
                    loadstr.AppendLine("                    this.add(item);");
                    loadstr.AppendLine("                }");
                }
                else if (arrClass.ElementType == "BigDecimal")
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) instanceof SoapPrimitive) {");
                    loadstr.AppendLine("                    SoapPrimitive pi = (SoapPrimitive) property.getProperty(loop);");
                    loadstr.AppendLine("                    BigDecimal item = BigDecimal.valueOf(Double.parseDouble(pi.toString()));");
                    loadstr.AppendLine("                    this.add(item);");
                    loadstr.AppendLine("                }");
                }
                else if (arrClass.ElementType == "Object")
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) != null) {");
                    loadstr.AppendLine("                    this.add((Object) property.getProperty(loop));");
                    loadstr.AppendLine("                }");
                }
                else
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) instanceof SoapObject) {");
                    loadstr.AppendLine("                    SoapObject so = (SoapObject) property.getProperty(loop);");
                    loadstr.AppendFormat("                  {0} item = new {0}(); \n", arrClass.ElementType);
                    loadstr.AppendLine("                    item.loadSoapObject(so);");
                    loadstr.AppendLine("                    this.add(item);");
                    loadstr.AppendLine("                }");

                    SoapClasses elementClass = WebService.SoapClasses.Where(x => x.Name == arrClass.ElementType).FirstOrDefault();
                    if (elementClass != null)
                    {
                        CreateComplexClass(elementClass);
                    }
                }

                arraystr = arraystr.Replace("%%LOADSOAPOBJECTS%%", loadstr.ToString());

                using (FileHelper file = new FileHelper(string.Concat(ProjectFolder, arrClass.Name, ".java")))
                {
                    file.Write(arraystr);
                }
                Utility.WriteTrace(string.Format("{0}.java Oluşturuldu", arrClass.Name));
                complexClasses.Add(arrClass.Name);
            }
            catch (Exception exc)
            {
                Utility.Hata(exc);
            }
        }
Esempio n. 2
0
        private void OutputElements(XmlSchemaParticle particle, string name)
        {
            SoapClasses newClass = this.GetClass(name);

            newClass.Name    = name;
            newClass.Type    = ClassType.Unknown;
            newClass.IsArray = name.StartsWith("ArrayOf");
            newClass.Output  = false;

            XmlSchemaSequence sequence = particle as XmlSchemaSequence;
            XmlSchemaChoice   choice   = particle as XmlSchemaChoice;
            XmlSchemaAll      all      = particle as XmlSchemaAll;

            if (sequence != null)
            {
                for (int i = 0; i < sequence.Items.Count; i++)
                {
                    XmlSchemaElement  childElement  = sequence.Items[i] as XmlSchemaElement;
                    XmlSchemaSequence innerSequence = sequence.Items[i] as XmlSchemaSequence;
                    XmlSchemaChoice   innerChoice   = sequence.Items[i] as XmlSchemaChoice;
                    XmlSchemaAll      innerAll      = sequence.Items[i] as XmlSchemaAll;

                    if (childElement != null)
                    {
                        SoapClassProperties newProp = new SoapClassProperties(XpoDefault.Session);
                        newProp.Name = childElement.Name;

                        newProp.PropertyClassType = childElement.SchemaTypeName.Name;
                        newProp.IsArray           = childElement.SchemaTypeName.Name.StartsWith("ArrayOf");
                        newClass.Properties.Add(newProp);
                        newClass.ElementType = JavaTypeConverter.ToElementJavaType(childElement.SchemaTypeName.Name);
                    }
                    else
                    {
                        OutputElements(sequence.Items[i] as XmlSchemaParticle, name);
                    }
                }
            }
            else if (choice != null)
            {
                for (int i = 0; i < choice.Items.Count; i++)
                {
                    XmlSchemaElement  childElement  = choice.Items[i] as XmlSchemaElement;
                    XmlSchemaSequence innerSequence = choice.Items[i] as XmlSchemaSequence;
                    XmlSchemaChoice   innerChoice   = choice.Items[i] as XmlSchemaChoice;
                    XmlSchemaAll      innerAll      = choice.Items[i] as XmlSchemaAll;

                    if (childElement != null)
                    {
                        SoapClassProperties newProp = new SoapClassProperties(XpoDefault.Session);
                        newProp.Name = childElement.Name;
                        newProp.PropertyClassType = childElement.SchemaTypeName.Name;
                        newProp.IsArray           = childElement.SchemaTypeName.Name.StartsWith("ArrayOf");
                        newClass.Properties.Add(newProp);
                    }
                    else
                    {
                        OutputElements(choice.Items[i] as XmlSchemaParticle, name);
                    }
                }
            }
            else if (all != null)
            {
                for (int i = 0; i < all.Items.Count; i++)
                {
                    XmlSchemaElement  childElement  = all.Items[i] as XmlSchemaElement;
                    XmlSchemaSequence innerSequence = all.Items[i] as XmlSchemaSequence;
                    XmlSchemaChoice   innerChoice   = all.Items[i] as XmlSchemaChoice;
                    XmlSchemaAll      innerAll      = all.Items[i] as XmlSchemaAll;

                    if (childElement != null)
                    {
                        SoapClassProperties newProp = new SoapClassProperties(XpoDefault.Session);
                        newProp.Name = childElement.Name;

                        newProp.PropertyClassType = childElement.SchemaTypeName.Name;
                        newProp.IsArray           = childElement.SchemaTypeName.Name.StartsWith("ArrayOf");
                        newClass.Properties.Add(newProp);
                    }
                    else
                    {
                        OutputElements(all.Items[i] as XmlSchemaParticle, name);
                    }
                }
            }
            newClass.Save();
            //this.ComplexTypes.Add(newClass);
        }