Exemplo n.º 1
0
        // 9
        /// <summary>
        /// Creates a synchronization agent that will handle a full synchronization between a client and a server.
        /// </summary>
        /// <param name="clientProvider">local provider to your client database</param>
        /// <param name="remoteOrchestrator">Remote Orchestrator already configured with a SyncProvider</param>
        /// <param name="options">Sync Options defining options used by your local provider (and remote provider if type of remoteOrchestrator is not a WebRemoteOrchestrator)</param>
        public SyncAgent(CoreProvider clientProvider, RemoteOrchestrator remoteOrchestrator, SyncOptions options = default)
            : this()
        {
            if (clientProvider is null)
            {
                throw new ArgumentNullException(nameof(clientProvider));
            }
            if (remoteOrchestrator is null)
            {
                throw new ArgumentNullException(nameof(remoteOrchestrator));
            }
            if (options == default)
            {
                options = new SyncOptions();
            }

            // Override remote orchestrator options, setup and scope name
            remoteOrchestrator.Options = options;

            var localOrchestrator = new LocalOrchestrator(clientProvider, options);

            this.LocalOrchestrator  = localOrchestrator;
            this.RemoteOrchestrator = remoteOrchestrator;
            this.EnsureOptionsAndSetupInstances();
        }
Exemplo n.º 2
0
        // 10
        /// <summary>
        /// Creates a synchronization agent that will handle a full synchronization between a client and a server.
        /// </summary>
        /// <param name="localOrchestrator">Local Orchestrator already configured with a SyncProvider</param>
        /// <param name="remoteOrchestrator">Remote Orchestrator already configured with a SyncProvider</param>
        /// <param name="scopeName">scope name</param>
        public SyncAgent(LocalOrchestrator localOrchestrator, RemoteOrchestrator remoteOrchestrator) : this()
        {
            if (localOrchestrator is null)
            {
                throw new ArgumentNullException(nameof(localOrchestrator));
            }
            if (remoteOrchestrator is null)
            {
                throw new ArgumentNullException(nameof(remoteOrchestrator));
            }

            this.LocalOrchestrator  = localOrchestrator;
            this.RemoteOrchestrator = remoteOrchestrator;
            this.EnsureOptionsAndSetupInstances();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create an agent based on orchestrators. The remote orchestrator could be of type RemoteOrchestrator (TCP connection) our WebClientOrchestrator (Http connection)
        /// </summary>
        /// <param name="localOrchestrator">local orchestrator using a local provider</param>
        /// <param name="remoteOrchestrator">remote orchestrator : RemoteOrchestrator or WebClientOrchestrator) </param>
        /// <param name="setup">Contains list of your tables. Not used if remote orchestrator is WebClientOrchestrator</param>
        /// <param name="options">Options. Only used on locally if remote orchestrator is WebClientOrchestrator</param>
        public SyncAgent(LocalOrchestrator localOrchestrator, IRemoteOrchestrator remoteOrchestrator,
                         SyncSetup setup = null, SyncOptions options = null)
        {
            if (remoteOrchestrator.Provider != null && !remoteOrchestrator.Provider.CanBeServerProvider)
            {
                throw new NotSupportedException();
            }

            // tables to add
            this.Setup = setup ?? new SyncSetup();

            // Create sync options if needed
            this.Options = options ?? new SyncOptions();

            // Add parameters
            this.Parameters = new SyncParameters();

            // Affect local and remote orchestrators
            this.LocalOrchestrator  = localOrchestrator;
            this.RemoteOrchestrator = remoteOrchestrator;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create an agent based on orchestrators. The remote orchestrator could be of type RemoteOrchestrator (TCP connection) our WebClientOrchestrator (Http connection)
        /// </summary>
        /// <param name="localOrchestrator">local orchestrator using a local provider</param>
        /// <param name="remoteOrchestrator">remote orchestrator : RemoteOrchestrator or WebClientOrchestrator) </param>
        /// <param name="tables">tables list</param>
        public SyncAgent(LocalOrchestrator localOrchestrator, IRemoteOrchestrator remoteOrchestrator, string[] tables)
            : this(localOrchestrator, remoteOrchestrator, new SyncSetup(tables))

        {
        }
Exemplo n.º 5
0
 /// <summary>
 /// Intercept the provider action when a scope is loaded from client database
 /// </summary>
 public static Guid OnClientScopeInfoLoaded(this LocalOrchestrator orchestrator, Func <ClientScopeInfoLoadedArgs, Task> action)
 => orchestrator.AddInterceptor(action);
Exemplo n.º 6
0
 /// <summary>
 /// Intercept the provider action when a client scope is about to be loaded from client database
 /// </summary>
 public static Guid OnClientScopeInfoLoading(this LocalOrchestrator orchestrator, Action <ClientScopeInfoLoadingArgs> action)
 => orchestrator.AddInterceptor(action);