コード例 #1
0
 /// <summary>
 /// Deletes the data structure from the reposiotry and tells all (subscribing) clients about it
 ///
 /// Override to implement custom logic
 /// </summary>
 /// <param name="model"></param>
 public virtual void Delete(DataSyncStructure model)
 {
     model = _store.GetByKey(model.Id);
     if (model != null)
     {
         _store.Remove(model.Id);
         Sync(DataSyncCommand.Delete, model);
     }
 }
コード例 #2
0
        /// <summary>
        /// Adds/Updates the data structure from in reposiotry and tells all (subscribing) clients about it.
        ///
        /// Override to implement custom logic
        /// </summary>
        /// <param name="model"></param>
        public virtual void Update(DataSyncStructure model)
        {
            var command = DataSyncCommand.Update;

            if (model.Id == Guid.Empty)
            {
                model.Id = Guid.NewGuid();
                command  = DataSyncCommand.Add;
            }

            model = _store.AddOrUpdate(model.Id, model);
            Sync(command, model);
        }
コード例 #3
0
 /// <summary>
 /// Will do a PUBLISH of changes by default, override to implement specific logic and/or RPC
 /// </summary>
 /// <param name="command"></param>
 /// <param name="model"></param>
 protected virtual void Sync(string command, DataSyncStructure model)
 {
     Controller.PublishToAll(model, string.Format("{0}:{1}", command, model.Topic));
 }