LocalProvider 属性

获取或设置一个派生自 ClientSyncProvider 的对象,该对象用于与本地数据存储区进行通信。

命名空间:  Microsoft.Synchronization
程序集:  Microsoft.Synchronization.Data(在 Microsoft.Synchronization.Data.dll 中)

语法

声明
Public Property LocalProvider As SyncProvider
    Get
    Set
用法
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);
}
member LocalProvider : SyncProvider with get, set
function get LocalProvider () : SyncProvider
function set LocalProvider (value : SyncProvider)

属性值

类型:Microsoft.Synchronization. . :: . .SyncProvider
一个派生自 ClientSyncProvider 的对象。

异常

异常 条件
InvalidCastException

value 无法转换为 ClientSyncProvider

示例

下面的代码示例创建一个派生自 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 命名空间