Ejemplo n.º 1
0
        public static void CreateOperationInputOutputTypes(Namespace ns)
        {
            foreach (Interface intf in ns.Declarations.OfType<Interface>())
            {
                foreach(Operation operation in intf.Operations)
                {
                    StructType inputType =
                        new StructType()
                        {
                            Name = operation.Name,
                            Namespace = intf.Namespace
                        };
                    foreach (OperationParameter param in operation.Parameters)
                    {
                        inputType.Fields.Add(
                            new StructField()
                            {
                                Name = param.Name,
                                Type = param.Type
                            });
                    }
                    StructType outputType =
                        new StructType()
                        {
                            Name = operation.Name + "Response",
                            Namespace = intf.Namespace
                        };
                    outputType.Fields.Add(
                        new StructField()
                        {
                            Name = operation.Name + "Result",
                            Type = operation.ReturnType
                        });

                    operation.InputType = inputType;
                    operation.OutputType = outputType;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Processes struct node.
        /// </summary>
        /// <param name="node">The node.</param>
        private void Process_StructType(dynamic node)
        {
            StructType structType = new StructType();

            // Map source location and node to object
            structType.AddMetaInfo(new SourceLocationInfo(node, context));
            context.AddObject(node, structType);

            // Namespace (from parent)
            try
            {
                NameContext.Current.CheckName(node.Name, typeof(EnumType), typeof(StructType), typeof(ExceptionType), typeof(ClaimsetType));
                structType.Namespace = (Namespace)NameContext.Current.Scope;
            }
            catch (NameCollisionException exception)
            {
                Error_NameExists(structType, exception);
            }

            // Name (obligatory)
            structType.Name = node.Name;

            // Fields are not processed yet

            // SuperType is not processed yet
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Declare a new struct type in the current scope based on an actual class.
        /// </summary>
        /// <remarks>
        /// Used to declare predefined struct types representing existing classes in metamodel.
        /// </remarks>
        /// <param name="type">The class type.</param>
        private void Process_ModelStruct(System.Type type)
        {
            if (NameContext.Current.Scope.Model.Instances.OfType<Type>().Count(t => t.UnderlyingType == type) == 0)
            {
                StructType structType = new StructType();

                // Namespace
                structType.Namespace = (Namespace)NameContext.Current.Scope;

                // Name
                structType.Name = AttributeHelpers.GetTypeName(type);

                // Underlying type
                structType.UnderlyingType = type;

                // Hidden
                structType.AddMetaInfo(new HiddenInfo());

                // Enter scope
                using (new NameContextScope(structType))
                {
                    // Fields
                    foreach (PropertyInfo property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public))
                    {
                        StructField structField = new StructField();
                        structField.Name = AttributeHelpers.GetMemberName(property);
                        structField.Type = BuiltInType.GetBuiltInType(property.PropertyType);
                        structField.Struct = structType;
                        // Hidden
                        structField.AddMetaInfo(new HiddenInfo());
                    }
                }
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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);
            }
        }