INotifyingChangeApplierTarget.TryGetDestinationVersion メソッド

同期先レプリカに格納されている項目のバージョンを取得します。

名前空間: Microsoft.Synchronization
アセンブリ: Microsoft.Synchronization (microsoft.synchronization.dll 内)

構文

'宣言
Function TryGetDestinationVersion ( _
    sourceChange As ItemChange, _
    <OutAttribute> ByRef destinationVersion As ItemChange _
) As Boolean
'使用
Dim instance As INotifyingChangeApplierTarget
Dim sourceChange As ItemChange
Dim destinationVersion As ItemChange
Dim returnValue As Boolean

returnValue = instance.TryGetDestinationVersion(sourceChange, destinationVersion)
bool TryGetDestinationVersion (
    ItemChange sourceChange,
    out ItemChange destinationVersion
)
bool TryGetDestinationVersion (
    ItemChange^ sourceChange, 
    [OutAttribute] ItemChange^% destinationVersion
)
boolean TryGetDestinationVersion (
    ItemChange sourceChange, 
    /** @attribute OutAttribute() */ /** @ref */ ItemChange destinationVersion
)
JScript does not support passing value-type arguments by reference.

パラメーター

  • sourceChange
    同期元プロバイダーから送信される項目変更です。
  • destinationVersion
    同期先レプリカの項目のバージョンを含む項目変更を返します。

戻り値

項目が同期先レプリカで見つかった場合は true、それ以外の場合は false です。

解説

このメソッドは、同期先のバージョンが ApplyChanges メソッドに渡されない場合に NotifyingChangeApplier によって呼び出されます。TryGetDestinationVersion は、変更適用元に送信される変更バッチ内の変更ごとに 1 回呼び出されます。

このメソッドは省略可能で、NotImplementedException をスローすることができます。ただし、プロバイダーが制約の競合を報告する場合や、同期コミュニティ内の他のプロバイダーがマージによって制約の競合を解決する場合を除きます。このような場合はいずれも、このメソッドを実装する必要があります。

次の例では、Metadata Storage Service を使用して、項目に含まれている変更単位の同期先バージョンを取得します。

Public Function TryGetDestinationVersion(ByVal sourceChange As ItemChange, ByRef destinationVersion As ItemChange) As Boolean Implements INotifyingChangeApplierTarget.TryGetDestinationVersion
    Dim found As Boolean = False
    ' Get the item metadata from the metadata store.
    Dim itemMeta As ItemMetadata = _ContactStore.ContactReplicaMetadata.FindItemMetadataById(sourceChange.ItemId)
    If itemMeta IsNot Nothing Then
        ' The item metadata exists, so translate the change unit metadata to the proper format and
        ' return the item change object.
        Dim cuChange As ChangeUnitChange
        Dim cuChanges As New List(Of ChangeUnitChange)()
        For Each cuMeta As ChangeUnitMetadata In itemMeta.GetChangeUnitEnumerator()
            cuChange = New ChangeUnitChange(IdFormats, cuMeta.ChangeUnitId, cuMeta.ChangeUnitVersion)
            cuChanges.Add(cuChange)
        Next
        destinationVersion = New ItemChange(IdFormats, _ContactStore.ContactReplicaMetadata.ReplicaId, sourceChange.ItemId, ChangeKind.Update, itemMeta.CreationVersion, cuChanges)

        found = True
    Else
        destinationVersion = Nothing
    End If
    Return found
End Function
public bool TryGetDestinationVersion(ItemChange sourceChange, out ItemChange destinationVersion)
{
    bool found = false;
    // Get the item metadata from the metadata store.
    ItemMetadata itemMeta = _ContactStore.ContactReplicaMetadata.FindItemMetadataById(sourceChange.ItemId);
    if (null != itemMeta)
    {
        // The item metadata exists, so translate the change unit metadata to the proper format and
        // return the item change object.
        ChangeUnitChange cuChange;
        List<ChangeUnitChange> cuChanges = new List<ChangeUnitChange>();
        foreach (ChangeUnitMetadata cuMeta in itemMeta.GetChangeUnitEnumerator())
        {
            cuChange = new ChangeUnitChange(IdFormats, cuMeta.ChangeUnitId, cuMeta.ChangeUnitVersion);
            cuChanges.Add(cuChange);
        }
        destinationVersion = new ItemChange(IdFormats, _ContactStore.ContactReplicaMetadata.ReplicaId, sourceChange.ItemId,
            ChangeKind.Update, itemMeta.CreationVersion, cuChanges);

        found = true;
    }
    else
    {
        destinationVersion = null;
    }
    return found;
}

参照

リファレンス

INotifyingChangeApplierTarget インターフェイス
INotifyingChangeApplierTarget メンバー
Microsoft.Synchronization 名前空間