Exemplo n.º 1
0
 public List <Change> ApplyChanges(ModelClient sourceClient, string changesData)
 {
     lock (this)
     {
         var           otherClients = _clients.Where(s => s != sourceClient).ToList();
         List <Change> changes      = new List <Change>();
         using (var context = DeserializingContext.FromString(changesData, _serializer))
         {
             context.Reader.Read();
             while (context.Reader.Read() && context.Reader.TokenType != JsonToken.EndArray)
             {
                 var change = DeserializeAndApplyChange(context);
                 if (!change.Ignored) // ignored change due to unsync
                 {
                     Subscriptions.NotifyChange(sourceClient, change.Type, change.Handler, change.Key, change.Value);
                     if (change.OldValue != null)
                     {
                         DetachOldItem(sourceClient, change.OldValue);
                     }
                     if (change.Value != null)
                     {
                         AttachNewItem(sourceClient, change.Value);
                     }
                     otherClients.ForEach(client => AddChange(client, change.Type, change.Path, change.Handler, change.Key, change.Value));
                     changes.Add(change);
                 }
             }
         }
         return(changes);
     }
 }
Exemplo n.º 2
0
 public object Deserialize(Type type, string str)
 {
     using (var context = DeserializingContext.FromString(str, _serializer))
     {
         context.Reader.Read();
         return(DeserializeMemeberValue(_configurations[type], null, null, context));
     }
 }