toXml method

XmlElement toXml(
  1. String elemName, {
  2. List<XmlAttribute>? attributes,
})

Implementation

_s.XmlElement toXml(String elemName, {List<_s.XmlAttribute>? attributes}) {
  final allowedMethods = this.allowedMethods;
  final allowedOrigins = this.allowedOrigins;
  final allowedHeaders = this.allowedHeaders;
  final exposeHeaders = this.exposeHeaders;
  final maxAgeSeconds = this.maxAgeSeconds;
  final $children = <_s.XmlNode>[
    if (allowedHeaders != null)
      ...allowedHeaders
          .map((e) => _s.encodeXmlStringValue('AllowedHeader', e)),
    ...allowedMethods.map((e) => _s.encodeXmlStringValue('AllowedMethod', e)),
    ...allowedOrigins.map((e) => _s.encodeXmlStringValue('AllowedOrigin', e)),
    if (exposeHeaders != null)
      ...exposeHeaders.map((e) => _s.encodeXmlStringValue('ExposeHeader', e)),
    if (maxAgeSeconds != null)
      _s.encodeXmlIntValue('MaxAgeSeconds', maxAgeSeconds),
  ];
  final $attributes = <_s.XmlAttribute>[
    ...?attributes,
  ];
  return _s.XmlElement(
    _s.XmlName(elemName),
    $attributes,
    $children,
  );
}