Freigeben über


SyncAgent-Klasse

Das SyncAgent-Objekt steuert die Synchronisierung.

Namespace:  Microsoft.Synchronization
Assembly:  Microsoft.Synchronization.Data (in Microsoft.Synchronization.Data.dll)

Syntax

'Declaration
Public Class SyncAgent _
    Implements IDisposable
'Usage
Dim instance As SyncAgent
public class SyncAgent : IDisposable
public ref class SyncAgent : IDisposable
type SyncAgent =  
    class
        interface IDisposable
    end
public class SyncAgent implements IDisposable

Hinweise

Der SyncAgent durchläuft alle zu synchronisierenden Tabellen und ruft den Clientsynchronisierungsanbieter auf, um Änderungen in der Clientdatenbank abzurufen und anzuwenden. Anschließend wird der Serversynchronisierungsanbieter aufgerufen, um Änderungen in der Serverdatenbank abzurufen und anzuwenden.

Beispiele

Das folgende Codebeispiel erstellt eine Klasse, die von der SyncAgent-Klasse abgeleitet ist. Die Klasse instanziiert einen Clientsynchronisierungsanbieter und einen Serversynchronisierungsanbieter, erstellt eine Synchronisierungsgruppe und fügt die Customer-Tabelle hinzu. Beim Hinzufügen der Tabelle werden auch die Synchronisierungsrichtung und eine Tabellenerstellungsoption festgelegt. Eine Darstellung dieses Codes im Kontext eines vollständigen Beispiels finden Sie unter Vorgehensweise: Bidirektionaler Austausch inkrementeller Datenänderungen zwischen Client und Server.

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

Vererbungshierarchie

System. . :: . .Object
  Microsoft.Synchronization..::..SyncAgent

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Siehe auch

Verweis

SyncAgent-Member

Microsoft.Synchronization-Namespace