'C# ADAPT ISOv4Plugin iso xml custom attributes

ADAPT https://github.com/ADAPT/ISOv4Plugin

I need to add a custom attribute to the output xml nodes.

I cannot find any extensions/functions to add custom attribute to: ISOCustomer ISOFarm ISOPartField ISOGUidanceGroup

The way that works for me is to extend one of the base classes

 public class ISOGuidanceGroupVG : **ISOGuidanceGroup**
    {
        public string GuidanceGroupType { get; set; }

        public override XmlWriter WriteXML(XmlWriter xmlBuilder)
        {
            xmlBuilder.WriteStartElement("GGP");
            xmlBuilder.WriteXmlAttribute("A", GuidanceGroupId);
            xmlBuilder.WriteXmlAttribute("B", GuidanceGroupDesignator);
            **xmlBuilder.WriteXmlAttribute("CUSTOM_ATTRIBUTE", "value");**

            //NOTE  needed to copy implementation from ISOElement.WriteXML
            // base.WriteXML(xmlBuilder);

            if (XmlComments != null)
            {
                XmlComments.ForEach(delegate (string s)
                {
                    xmlBuilder.WriteComment(s);
                });
            }

            foreach (ISOGuidancePattern guidancePattern in GuidancePatterns)
            {
                guidancePattern.WriteXML(xmlBuilder);
            }

            foreach (ISOPolygon boundaryPolygon in BoundaryPolygons)
            {
                boundaryPolygon.WriteXML(xmlBuilder);
            }

            xmlBuilder.WriteEndElement();
            return xmlBuilder;
        }
    }

xml node sample

Now the question is, how do I do it in some native way...?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source