Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void marshallAsElement(org.jboss.as.controller.AttributeDefinition attribute, org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, javax.xml.stream.XMLStreamWriter writer) throws javax.xml.stream.XMLStreamException
            public override void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, bool marshallDefault, XMLStreamWriter writer)
            {
                if (attribute is ObjectListAttributeDefinition)
                {
                    attribute = getValueType(attribute, typeof(ObjectListAttributeDefinition));
                }

                if (!(attribute is ObjectTypeAttributeDefinition))
                {
                    throw new XMLStreamException(string.Format("Attribute of class {0} is expected, but {1} received", "ObjectTypeAttributeDefinition", attribute.GetType().Name));
                }

                AttributeDefinition[] valueTypes;
                valueTypes = CustomMarshaller.getValueTypes(attribute, typeof(ObjectTypeAttributeDefinition));

                writer.writeStartElement(attribute.XmlName);
                foreach (AttributeDefinition valueType in valueTypes)
                {
                    valueType.marshallAsElement(resourceModel, marshallDefault, writer);
                }
                writer.writeEndElement();
            }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void marshallAsElement(org.jboss.as.controller.AttributeDefinition attribute, org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, javax.xml.stream.XMLStreamWriter writer) throws javax.xml.stream.XMLStreamException
            public override void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, bool marshallDefault, XMLStreamWriter writer)
            {
                Debug.Assert(attribute is ObjectListAttributeDefinition);
                ObjectListAttributeDefinition list = ((ObjectListAttributeDefinition)attribute);

                ObjectTypeAttributeDefinition objectType = (ObjectTypeAttributeDefinition)CustomMarshaller.getValueType(list, typeof(ObjectListAttributeDefinition));

                AttributeDefinition[] valueTypes = CustomMarshaller.getValueTypes(list, typeof(ObjectTypeAttributeDefinition));

                if (resourceModel.hasDefined(attribute.Name))
                {
                    writer.writeStartElement(attribute.XmlName);
                    foreach (ModelNode element in resourceModel.get(attribute.Name).asList())
                    {
                        writer.writeStartElement(objectType.XmlName);
                        foreach (AttributeDefinition valueType in valueTypes)
                        {
                            valueType.AttributeMarshaller.marshallAsElement(valueType, element, false, writer);
                        }
                        writer.writeEndElement();
                    }
                    writer.writeEndElement();
                }
            }