共用方式為


SyncAgent.LocalProvider 屬性

取得或設定衍生自 ClientSyncProvider 的物件,該提供者是用來與本機資料存放區通訊。

命名空間: Microsoft.Synchronization
組件: Microsoft.Synchronization.Data (在 microsoft.synchronization.data.dll)

語法

'宣告
Public Property LocalProvider As SyncProvider
'用途
Dim instance As SyncAgent
Dim value As SyncProvider

value = instance.LocalProvider

instance.LocalProvider = value
public SyncProvider LocalProvider { get; set; }
public:
property SyncProvider^ LocalProvider {
    SyncProvider^ get ();
    void set (SyncProvider^ value);
}
/** @property */
public SyncProvider get_LocalProvider ()

/** @property */
public void set_LocalProvider (SyncProvider value)
public function get LocalProvider () : SyncProvider

public function set LocalProvider (value : SyncProvider)

屬性值

衍生自 ClientSyncProvider 的物件。

範例

下列程式碼範例會建立衍生自 SyncAgent 的類別。此類別會具現化用戶端同步處理提供者和伺服器同步處理提供者、建立同步處理群組,並且加入 Customer 資料表。加入此資料表時,也會一併指定同步處理方向和資料表建立選項。若要在完整範例的內容中檢視這段程式碼,請參閱 HOW TO:交換用戶端和伺服器之間的雙向增量資料變更

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