0
如果我有一個實現IEditableObject Address類,我可能有EndEdit中實現這樣的:如何使IEditableObject.EndEdit成爲原子?
public void EndEdit()
{
// BeginEdit would have set _editInProgress and save to *Editing fields
if (_editInProgress)
{
_line1 = _line1Editing;
_line2 = _line2Editing;
_city = _cityEditing;
_state = _stateEditing;
_postalCode = _postalCodeEditing;
_editInProgress = false;
}
}
如果在_City異常,則_line1,_line2,可能還有_city應該恢復。 此問題不限於EndEdit但可能在其他地方也可以找到。