コード例 #1
0
 void OnChange(SyncRepo <TKey, TValue, TChgSet> .Change chg)
 {
     if ((chg.State & SyncRepo <TKey, TValue, TChgSet> .EState.Added) != 0)
     {
         var x = new ProtoCreateMessage <TKey, TValue, TChgSet>()
         {
             RepoId = _repoId,
             Key    = chg.Key,
             ChgSet = chg.ChgSet
         };
         _protoComm.SendMessage(_msgIds.Create, x);
     }
     else
     if ((chg.State & SyncRepo <TKey, TValue, TChgSet> .EState.Removed) != 0)
     {
         var x = new ProtoRemoveMessage <TKey>()
         {
             RepoId = _repoId,
             Key    = chg.Key
         };
         _protoComm.SendMessage(_msgIds.Remove, x);
     }
     else
     {
         var x = new ProtoUpdateMessage <TKey, TValue, TChgSet>()
         {
             RepoId = _repoId,
             Key    = chg.Key,
             ChgSet = chg.ChgSet
         };
         _protoComm.SendMessage(_msgIds.Update, x);
     }
 }
コード例 #2
0
        public ProtoNetAdapter(SyncRepo <TKey, TValue, TChgSet> repo, int repoId, IProtoComm protoComm)
        {
            _repo      = repo;
            _repoId    = repoId;
            _protoComm = protoComm;

            _msgIds = RegisterMessageTypes(protoComm.TypeMap);
        }