記錄嘗試將變更套用至項目時所發生的可復原錯誤。
命名空間: Microsoft.Synchronization.SimpleProviders
組件: Microsoft.Synchronization.SimpleProviders (在 microsoft.synchronization.simpleproviders.dll)
語法
'宣告
Public Sub RecordRecoverableErrorForChange ( _
errorData As RecoverableErrorData _
)
'用途
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
)
參數
- errorData
與所報告之可復原錯誤相關聯的 RecoverableErrorData 物件。
例外
| 例外狀況型別 | 條件 |
|---|---|
有多項可復原錯誤,或是在已經失效的物件上嘗試進行變更。 |
範例
下列程式碼範例示範 DeleteItem 方法的實作,此方法會將刪除套用到記憶體中的範例資料存放區。如果無法套用刪除,這個方法便會記錄可復原錯誤。若要在完整應用程式的內容中檢視這段程式碼,請參閱 Sync Framework SDK 及 Code Gallery 中的 "Sync101 using Simple Sync Provider" 應用程式。
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
請參閱
參考
RecoverableErrorReportingContext 類別
RecoverableErrorReportingContext 成員
Microsoft.Synchronization.SimpleProviders 命名空間