For messages within MessageBox / LoggerSink / throwException interpolated strings ($"...{myVar}...") should not be used.
xMessgeBox.Show and LoggerSink.PushMessage go through l.Translate with success only if they contain strings without parameters.
Any parameter requires an explicit call of l.Translate (which is similar to a string.format command).
throw new Exception(l.Translate("Mehrwertsteuer Array konnte nicht berechnet werden."));
xMessageBox.Show(l.Translate("Gebinde nicht vorhanden),....);
answer = xMessageBox.Show(l.Translate("Gebinde nicht vorhanden. Soll es erstellt werden?"), "Abfrage", MessageBoxButton.YesNo);
if (answer == MessageBoxResult.Yes)
{
//Create container
this.CreateGebinde(gebindeNr);
return;
}
LoggerSink.PushMessage(this, "Speichern erfolgreich.", Severity.Confirmation);
If more than a Message (a string) is needed after an exception occurred, we can use custom exceptions.
public class SchichtplanSaveException : Exception
{
public DataRow faultyRow;
public SchichtplanSaveException() { }
public SchichtplanSaveException(string message) : base(message) { }
public SchichtplanSaveException(string message, DataRow row) : base(message) { faultyRow = row; }
public SchichtplanSaveException(string message, Exception inner) : base(message, inner) { }
}
public override int OnPreSave()
{
try
{
BusObj.SaveTest();
}
catch (SchichtplanSaveException ex)
{
xMessageBox.ShowException(ex, "Speichern abgebrochen.");
if (ex.faultyRow != null) dxgSchichtplanPos.SelectedRow = ex.faultyRow;
return -1;
}
return base.OnPreSave();
}