Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new PollingDataSyncService&lt;T&gt; instance
 /// </summary>
 /// <param name="interval">Polling rate in milliseconds.</param>
 /// <param name="apiService">The IRESTService instance to be used to make API calls.</param>
 /// <param name="dataSyncDelegate">Will be invoked as the synchronization method.</param>
 public PollingDataSyncService(int interval, IRESTService apiService, DataSyncDelegate <T> dataSyncDelegate = null)
 {
     _timer          = new Timer(interval);
     _timer.Elapsed += SyncWithDatabase;
     _repository     = new List <T>();
     _apiService     = apiService;
     if (dataSyncDelegate != null)
     {
         _dataSyncDelegate = dataSyncDelegate;
     }
     else
     {
         _dataSyncDelegate = new DataSyncDelegate <T>(DefaultDatabaseFetchFunc);
     }
     _apiResourceUri = new StringBuilder(typeof(T).Name.ToLower()).Append("s").ToString();
 }
Exemplo n.º 2
0
        /// <summary>
        ///     注册数据同步完成的回调函数
        /// </summary>
        /// <param name="cb">数据同步完成的回调函数</param>
        public static void RegCompleteCb(DataSyncDelegate cb)
        {
            var userData = DelegateConverter.ConvertToIntPtr(cb);

            DataSyncNativeMethods.nim_data_sync_reg_complete_cb(OnDataSyncCompleted, userData);
        }