RecoverableErrorReportingContext.RecordRecoverableErrorForChange Método
Registra un error recuperable que se produjo al intentar aplicar un cambio a un elemento.
Espacio de nombres: Microsoft.Synchronization.SimpleProviders
Ensamblado: Microsoft.Synchronization.SimpleProviders (en microsoft.synchronization.simpleproviders.dll)
Sintaxis
'Declaración
Public Sub RecordRecoverableErrorForChange ( _
errorData As RecoverableErrorData _
)
'Uso
Dim instance As RecoverableErrorReportingContext
Dim errorData As RecoverableErrorData
instance.RecordRecoverableErrorForChange(errorData)
public void RecordRecoverableErrorForChange (
RecoverableErrorData errorData
)
public:
void RecordRecoverableErrorForChange (
RecoverableErrorData^ errorData
)
public void RecordRecoverableErrorForChange (
RecoverableErrorData errorData
)
public function RecordRecoverableErrorForChange (
errorData : RecoverableErrorData
)
Parámetros
- errorData
Objeto RecoverableErrorData asociado al error recuperable que se notifica.
Excepciones
Tipo de excepción | Condición |
---|---|
Se produjeron varios errores recuperables, o se intentó un cambio en un objeto que ya no es válido. |
Ejemplo
En el ejemplo de código siguiente se muestra una implementación del método DeleteItem que aplica eliminaciones a un almacén de datos de ejemplo en memoria. El método registra un error recuperable si la eliminación no se puede aplicar. Para consultar este código en el contexto de una aplicación completa, vea la aplicación "Sync101 using Simple Sync Provider"
que está disponible en Sync Framework SDK y en Code Gallery.
public override void DeleteItem(ItemFieldDictionary keyAndExpectedVersion,
RecoverableErrorReportingContext recoverableErrorReportingContext,
out bool commitKnowledgeAfterThisItem)
{
IDictionary<uint, ItemField> expectedFields = (IDictionary<uint, ItemField>)keyAndExpectedVersion;
ulong id = (ulong)expectedFields[CUSTOM_FIELD_ID].Value;
if (_store.Contains(id))
{
_store.DeleteItem(id);
}
else
{
// If the item to delete does not exist, record an error on this change and
// continue with the rest of the session.
recoverableErrorReportingContext.RecordRecoverableErrorForChange(new RecoverableErrorData(new Exception("Item not found in the store")));
}
commitKnowledgeAfterThisItem = false;
}
Public Overrides Sub DeleteItem(ByVal keyAndExpectedVersion As ItemFieldDictionary, ByVal recoverableErrorReportingContext As RecoverableErrorReportingContext, ByRef commitKnowledgeAfterThisItem As Boolean)
Dim expectedFields As IDictionary(Of UInteger, ItemField) = DirectCast(keyAndExpectedVersion, IDictionary(Of UInteger, ItemField))
Dim id As ULong = CULng(expectedFields(CUSTOM_FIELD_ID).Value)
If _store.Contains(id) Then
_store.DeleteItem(id)
Else
' If the item to delete does not exist, record an error on this change and
' continue with the rest of the session.
recoverableErrorReportingContext.RecordRecoverableErrorForChange(New RecoverableErrorData(New Exception("Item not found in the store")))
End If
commitKnowledgeAfterThisItem = False
End Sub
Vea también
Referencia
RecoverableErrorReportingContext Clase
RecoverableErrorReportingContext Miembros
Microsoft.Synchronization.SimpleProviders Espacio de nombres