共用方式為


IChangeDataRetriever.LoadChangeData 方法

在衍生類別中覆寫時,這個方法會擷取變更的項目資料。

命名空間: Microsoft.Synchronization
組件: Microsoft.Synchronization (在 microsoft.synchronization.dll)

語法

'宣告
Function LoadChangeData ( _
    loadChangeContext As LoadChangeContext _
) As Object
'用途
Dim instance As IChangeDataRetriever
Dim loadChangeContext As LoadChangeContext
Dim returnValue As Object

returnValue = instance.LoadChangeData(loadChangeContext)
Object LoadChangeData (
    LoadChangeContext loadChangeContext
)
Object^ LoadChangeData (
    LoadChangeContext^ loadChangeContext
)
Object LoadChangeData (
    LoadChangeContext loadChangeContext
)
function LoadChangeData (
    loadChangeContext : LoadChangeContext
) : Object

參數

  • loadChangeContext
    用來描述應該擷取資料之變更的中繼資料。

傳回值

變更的項目資料。

備註

來源提供者會判斷這個方法所傳回的物件型別。此物件可以非常簡單 (就像 Boxed 實值型別一樣),也可以很複雜 (就像是包含進階資料擷取之方法的類別一樣)。

範例

下列範例將示範如何實作 LoadChangeData 方法,以便擷取一組指定之變更單位的資料。這個範例會將資料傳回成以疏鬆方式填入的字串陣列。

Public Function LoadChangeData(ByVal loadChangeContext As LoadChangeContext) As Object Implements IChangeDataRetriever.LoadChangeData
    ' Sanity check to ensure the data array is not overrun.
    If Contact.ChangeUnitFieldCount < loadChangeContext.ItemChange.ChangeUnitChanges.Count Then
        Throw New ArgumentOutOfRangeException("LoadChangeData received too many change unit changes.")
    End If

    ' Get the ID of the item to return.
    Dim itemId As SyncId = loadChangeContext.ItemChange.ItemId

    ' Create a string array to hold the data for each change unit. Some of the elements of this array
    ' may be empty.
    Dim contactData As String() = New String(Contact.ChangeUnitFieldCount - 1) {}

    ' Enumerate the change units to retrieve.
    For iChange As Integer = 0 To loadChangeContext.ItemChange.ChangeUnitChanges.Count - 1
        ' Retrieve data for the specified change unit and put the data into the appropriate
        ' place in the string array.
        Dim icu As Integer = loadChangeContext.ItemChange.ChangeUnitChanges(iChange).ChangeUnitId.GetByteId()
        contactData(icu) = _ContactStore.GetContactData(itemId, loadChangeContext.ItemChange.ChangeUnitChanges(iChange).ChangeUnitId)
    Next
    Return contactData
End Function
public object LoadChangeData(LoadChangeContext loadChangeContext)
{
    // Sanity check to ensure the data array is not overrun.
    if (Contact.ChangeUnitFieldCount < loadChangeContext.ItemChange.ChangeUnitChanges.Count)
    {
        throw new ArgumentOutOfRangeException("LoadChangeData received too many change unit changes.");
    }

    // Get the ID of the item to return.
    SyncId itemId = loadChangeContext.ItemChange.ItemId;

    // Create a string array to hold the data for each change unit. Some of the elements of this array
    // may be empty.
    string[] contactData = new string[Contact.ChangeUnitFieldCount];

    // Enumerate the change units to retrieve.
    for (int iChange = 0; iChange < loadChangeContext.ItemChange.ChangeUnitChanges.Count; iChange++)
    {
        // Retrieve data for the specified change unit and put the data into the appropriate
        // place in the string array.
        int icu = loadChangeContext.ItemChange.ChangeUnitChanges[iChange].ChangeUnitId.GetByteId();
        contactData[icu] = _ContactStore.GetContactData(itemId,
            loadChangeContext.ItemChange.ChangeUnitChanges[iChange].ChangeUnitId);
    }
    return contactData;
}

請參閱

參考

IChangeDataRetriever 介面
IChangeDataRetriever 成員
Microsoft.Synchronization 命名空間