示例#1
0
        // Deklarálja az objektumokat
        private void Declare()
        {
            // service
            var services = from c in store
                           where c.objectType == StoreItemType.service
                           select c;

            Wr("Declare services:");
            foreach (StoreItem service in services)
            {
                Endpoint ep = new Endpoint()
                {
                    Name = (string)service.definition.Attribute("name")
                };
                service.objRef = ep;
                Wr("   " + ep.Name);
            }

            // binding
            var bindings = from c in store
                           where c.objectType == StoreItemType.binding
                           select c;

            Wr("Declare bindings:");
            foreach (StoreItem binding in bindings)
            {
                Binding bg = new Binding()
                {
                    Name = (string)binding.definition.Attribute("name")
                };
                binding.objRef = bg;
                Wr("   " + bg.Name);
            }
            // porttype
            var portTypes = from c in store
                            where c.objectType == StoreItemType.portType
                            select c;

            Wr("Declare porttypes:");
            foreach (StoreItem porttype in portTypes)
            {
                Interface ifa = new Interface()
                {
                    Name = (string)porttype.definition.Attribute("name")
                };
                porttype.objRef = ifa;
                Wr("   " + ifa.Name);
            }

            // simpleTypes
            var simpleTypes = from c in store
                              where c.objectType == StoreItemType.enumType
                              select c;

            Wr("Declare SimpleTypes:");
            foreach (StoreItem simpleType in simpleTypes)
            {
                EnumType et = new EnumType()
                {
                    Name = (string)simpleType.definition.Attribute("name")
                };
                simpleType.objRef = et;
                Wr("   " + et.Name);
            }

            // arrayType létrehozása
            // TODO: !!! mi van, ha több element van ???
            var arrayTypes = from c in store
                             where c.objectType == StoreItemType.complexType &&
                                   c.definition.Element(xsdNS + "sequence") != null &&
                                   c.definition.Element(xsdNS + "sequence").Element(xsdNS + "element") != null &&
                                   c.definition.Element(xsdNS + "sequence").Element(xsdNS + "element").Attribute("maxOccurs") != null &&
                                   (string)c.definition.Element(xsdNS + "sequence").Element(xsdNS + "element").Attribute("maxOccurs") != "1"
                             select c;

            Wr("Declare ArrayTypes:");
            foreach (StoreItem arrayType in arrayTypes)
            {
                ArrayType at = new ArrayType()
                {
                    Name = (string)arrayType.definition.Attribute("name")
                };
                arrayType.objRef = at;
                arrayType.objectType = StoreItemType.arrayType;
                Wr("   " + at.Name);
            }

            // ExceptionType
            // kiválasztjuk a portType-okat
            Wr("Declare ExceptionTypes:");
            foreach (StoreItem portType in portTypes)
            {
                XElement node = portType.definition;
                XElement def = node;
                // kiszűrjük a fault-tagek message attribútumát
                var faultsFromPorttype = from c in node.Descendants(wsdlNS + "fault")
                                         select c.Attribute("message");

                foreach (string faultMsgName in faultsFromPorttype)
                {
                    StoreItem message = SearchObject(StoreItemType.message, faultMsgName, def);
                    string referencedTypeName = null;
                    referencedTypeName = (string)message.definition.Element(wsdlNS + "part").Attribute("type");
                    def = message.definition;
                    if (referencedTypeName == null)
                    {
                        referencedTypeName = (string)message.definition.Element(wsdlNS + "part").Attribute("element");
                        StoreItem element = TrySearchObject(StoreItemType.unNamedElementType, referencedTypeName, def);

                        if (element != null)
                        {
                            referencedTypeName = (string)element.definition.Attribute("type");
                            def = element.definition;
                        }

                    }
                    StoreItem exceptionType = TrySearchObject(StoreItemType.complexType, referencedTypeName, def);
                    if (exceptionType != null)
                    {
                        ExceptionType et = new ExceptionType()
                            {
                                Name = exceptionType.name
                            };

                        exceptionType.objRef = et;
                        exceptionType.objectType = StoreItemType.exceptionType;
                        Wr("   " + et.Name);
                    }
                    else
                    {
                        Wr("Unable to make ExceptionType from " + referencedTypeName);
                        throw new  XmlException();
                    }
                }
            }

            // structType létrehozása (minden olyan complexType, ami nem arrayType, vagy ExceptionType)
            var structTypes = from c in store
                              where c.objectType == StoreItemType.complexType
                              select c;

            Wr("Declare StructTypes:");
            foreach (StoreItem structType in structTypes)
            {
                StructType at = new StructType()
                {
                    Name = (string)structType.definition.Attribute("name")
                };
                structType.objRef = at;
                structType.objectType = StoreItemType.structType;
                Wr("   " + at.Name);
            }
        }
示例#2
0
        // Deklarálja az objektumokat
        private void Declare()
        {
            // service
            var services = from c in readedElements
                           where c.objectType == ObjectTypes.service
                           select c;

            Wr("Declare services:");
            foreach (Collective service in services)
            {
                Endpoint ep = new Endpoint()
                {
                    Name = (string)service.definition.Attribute("name")
                };
                service.objRef = ep;
                Wr("   " + ep.Name);
            }

            // binding
            var bindings = from c in readedElements
                           where c.objectType == ObjectTypes.binding
                           select c;

            Wr("Declare bindings:");
            foreach (Collective binding in bindings)
            {
                Binding bg = new Binding()
                {
                    Name = (string)binding.definition.Attribute("name")
                };
                binding.objRef = bg;
                Wr("   " + bg.Name);
            }
            // porttype
            var portTypes = from c in readedElements
                            where c.objectType == ObjectTypes.porttype
                            select c;

            Wr("Declare porttypes:");
            foreach (Collective porttype in portTypes)
            {
                Interface ifa = new Interface()
                {
                    Name = (string)porttype.definition.Attribute("name")
                };
                porttype.objRef = ifa;
                Wr("   " + ifa.Name);
            }

            // simpleTypes
            var simpleTypes = from c in readedElements
                              where c.objectType == ObjectTypes.enumType
                              select c;

            Wr("Declare SimpleTypes:");
            foreach (Collective simpleType in simpleTypes)
            {
                EnumType et = new EnumType()
                {
                    Name = (string)simpleType.definition.Attribute("name")
                };
                simpleType.objRef = et;
                Wr("   " + et.Name);
            }

            // arrayType létrehozása
            // TODO: !!! mi van, ha több element van ???
            var arrayTypes = from c in readedElements
                             where c.objectType == ObjectTypes.complexType &&
                                   c.definition.Element(xmlNS + "sequence") != null &&
                                   c.definition.Element(xmlNS + "sequence").Element(xmlNS + "element") != null &&
                                   c.definition.Element(xmlNS + "sequence").Element(xmlNS + "element").Attribute("maxOccurs") != null &&
                                   (string)c.definition.Element(xmlNS + "sequence").Element(xmlNS + "element").Attribute("maxOccurs") != "1"
                             select c;

            Wr("Declare ArrayTypes:");
            foreach (Collective arrayType in arrayTypes)
            {
                ArrayType at = new ArrayType()
                {
                    Name = (string)arrayType.definition.Attribute("name")
                };
                arrayType.objRef = at;
                arrayType.objectType = ObjectTypes.arrayType;
                Wr("   " + at.Name);
            }

            // ExceptionType
            // kiválasztjuk a portType-okat
            Wr("Declare ExceptionTypes:");
            foreach (Collective portType in portTypes)
            {
                XElement node = portType.definition;

                // kiszűrjük a fault-tagek message attribútumát
                var faultsFromPorttype = from c in node.Descendants(wsdlNS + "fault")
                                         select c.Attribute("message");

                foreach (string faultMsgName in faultsFromPorttype)
                {
                    Collective message = SearchObject(ObjectTypes.message, faultMsgName, node);
                    var exceptionTypeNames = from c in message.definition.Descendants(wsdlNS + "part")
                                             select c.Attribute("element"); /// ?!?!?!

                    foreach (string excTypeName in exceptionTypeNames)
                    {
                        Collective exceptionType = SearchObject(ObjectTypes.complexType, excTypeName, node);
                        ExceptionType et = new ExceptionType()
                        {
                            Name = exceptionType.name
                        };

                        exceptionType.objRef = et;
                        exceptionType.objectType = ObjectTypes.exceptionType;
                        Wr("   " + et.Name);
                    }
                }
            }

            // structType létrehozása (minden olyan complexType, ami nem arrayType, vagy ExceptionType)
            var structTypes = from c in readedElements
                              where c.objectType == ObjectTypes.complexType
                              select c;

            Wr("Declare StructTypes:");
            foreach (Collective structType in structTypes)
            {
                StructType at = new StructType()
                {
                    Name = (string)structType.definition.Attribute("name")
                };
                structType.objRef = at;
                structType.objectType = ObjectTypes.structType;
                Wr("   " + at.Name);
            }
        }