Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagec#
public override string OnBeforeExport(string configuration, StringBuilder warnings)
{
  // deserialize the configuration string into a configuratino object
  var config = SerializationEx.Deserialize<FtpDeviceConfiguration>(configuration);
  var updated = false;
  
  // the ShouldReplaceValue method checks for null/empty as well as
  // global values. Globals are not cleared
  // This method is available in >= v16.1
  if (ShouldReplaceValue(config.SomeStringProperty))
  {
    config.SomeStringProperty = string.Empty;
    warnings.AppendLine("SomeStringProperty has been cleared.");
    updated = true;
  }

  // serialize the cleared configuration, if we cleared something
  return updated ? SerializationEx.Serialize(config, false) : configuration;
}

...