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。
此方法是可选方法,可引发 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 命名空间