共用方式為


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
)
abstract TryGetDestinationVersion : 
        sourceChange:ItemChange * 
        destinationVersion:ItemChange byref -> bool 
function TryGetDestinationVersion(
    sourceChange : ItemChange, 
    destinationVersion : ItemChange
) : boolean

參數

傳回值

型別:System. . :: . .Boolean
如果在目的地複寫中找到此項目則為 true,否則為 false。

備註

當目的地版本沒有傳遞給 ApplyChanges 方法時,NotifyingChangeApplier 就會呼叫這個方法。系統會針對傳送至變更套用者之變更批次中的每個變更呼叫 TryGetDestinationVersion 一次。

此方法是選用的,而且可能會擲回 NotImplementedException (除非提供者報告條件約束衝突,或同步處理社群中的其他任何提供者透過合併解決了條件約束衝突)。在其中一種情況下,您就必須實作這個方法。

範例

下列範例將示範如何使用中繼資料儲存服務來取得某個項目所包含變更單位的目的地版本。

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 命名空間