Поделиться через


Свойство RemoteProvider

Возвращает или задает объект, порожденный от ServerSyncProvider, который используется для сообщения с удаленным хранилищем данных.

Пространство имен:  Microsoft.Synchronization
Сборка:  Microsoft.Synchronization.Data (в Microsoft.Synchronization.Data.dll)

Синтаксис

'Декларация
Public Property RemoteProvider As SyncProvider
    Get
    Set
'Применение
Dim instance As SyncAgent
Dim value As SyncProvider

value = instance.RemoteProvider

instance.RemoteProvider = value
public SyncProvider RemoteProvider { get; set; }
public:
property SyncProvider^ RemoteProvider {
    SyncProvider^ get ();
    void set (SyncProvider^ value);
}
member RemoteProvider : SyncProvider with get, set
function get RemoteProvider () : SyncProvider
function set RemoteProvider (value : SyncProvider)

Значение свойства

Тип Microsoft.Synchronization. . :: . .SyncProvider
Объект, производный от ServerSyncProvider.

Исключения

Исключение Условие
InvalidCastException

Параметр value не может быть приведен к ServerSyncProvider.

Примеры

В следующем примере кода создается класс, производный от класса SyncAgent. Класс создает экземпляры службы синхронизации сервера и клиента, группу синхронизации и добавляет в нее таблицу Customer. При добавлении таблицы указывается направление синхронизации и режим создания таблицы. Чтобы просмотреть этот код в контексте полного примера, см. раздел Как установить двунаправленный обмен добавочными изменениями данных между клиентом и сервером.

public class SampleSyncAgent : SyncAgent
{
    public SampleSyncAgent()
    {            
        //Instantiate a client synchronization provider and specify it
        //as the local provider for this synchronization agent.
        this.LocalProvider = new SampleClientSyncProvider();

        //Instantiate a server synchronization provider and specify it
        //as the remote provider for this synchronization agent.
        this.RemoteProvider = new SampleServerSyncProvider();

        //Create a Customer SyncGroup. This is not required
        //for the single table we are synchronizing; it is typically
        //used so that changes to multiple related tables are 
        //synchronized at the same time.
        SyncGroup customerSyncGroup = new SyncGroup("Customer");

        //Add the Customer table: specify a synchronization direction of
        //Bidirectional, and that an existing table should be dropped.
        SyncTable customerSyncTable = new SyncTable("Customer");
        customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
        customerSyncTable.SyncDirection = SyncDirection.Bidirectional;
        customerSyncTable.SyncGroup = customerSyncGroup;
        this.Configuration.SyncTables.Add(customerSyncTable);
    }
}
Public Class SampleSyncAgent
    Inherits SyncAgent

    Public Sub New()
        'Instantiate a client synchronization provider and specify it
        'as the local provider for this synchronization agent.
        Me.LocalProvider = New SampleClientSyncProvider()

        'Instantiate a server synchronization provider and specify it
        'as the remote provider for this synchronization agent.
        Me.RemoteProvider = New SampleServerSyncProvider()

        'Create a Customer SyncGroup. This is not required
        'for the single table we are synchronizing; it is typically
        'used so that changes to multiple related tables are 
        'synchronized at the same time.
        Dim customerSyncGroup As New SyncGroup("Customer")

        'Add the Customer table: specify a synchronization direction of
        'Bidirectional, and that an existing table should be dropped.
        Dim customerSyncTable As New SyncTable("Customer")
        customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable
        customerSyncTable.SyncDirection = SyncDirection.Bidirectional
        customerSyncTable.SyncGroup = customerSyncGroup
        Me.Configuration.SyncTables.Add(customerSyncTable)

    End Sub 'New
End Class 'SampleSyncAgent

См. также

Справочник

SyncAgent Класс

Элементы SyncAgent

Пространство имен Microsoft.Synchronization