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
    对应该检索其数据的变更进行描述的元数据。

返回值

变更的项数据。

备注

源提供程序确定由此方法返回的对象的类型。该对象可以像装箱值类型一样简单,也可以像包含高级数据检索方法的类一样复杂。

示例

以下示例说明如何实现 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 命名空间