WriteAttributeValue method

void WriteAttributeValue(
  1. String localName,
  2. Object? value, [
  3. bool alwaysWriteEmptyString = false
])
Writes the attribute value. Does not emit empty String values. The local name of the attribute. Writes the attribute value. Optionally emits empty String values. The local name of the attribute. Always emit the empty String as the value. The value.

Implementation

//        /// <param name="value">The value.</param>
// void WriteAttributeValue(String localName, Object value)
//        {
//            this.WriteAttributeStringValue(localName, false /* alwaysWriteEmptyString */, value);
//        }

/// <summary>
/// Writes the attribute value.  Optionally emits empty String values.
/// </summary>
/// <param name="localName">The local name of the attribute.</param>
/// <param name="alwaysWriteEmptyString">Always emit the empty String as the value.</param>
/// <param name="value">The value.</param>
void WriteAttributeValue(String localName, Object? value,
    [bool alwaysWriteEmptyString = false]) {
  OutParam<String> stringValue = new OutParam();
  if (this.TryConvertObjectToString(value, stringValue)) {
    if ((stringValue.param != null) &&
        (alwaysWriteEmptyString || (stringValue.param!.length != 0))) {
      this.WriteAttributeString(localName, stringValue.param);
    }
  } else {
    throw new ServiceXmlSerializationException(
        "AttributeValueCannotBeSerialized(${value.runtimeType}, $localName)");
  }
}