示例#1
0
        public TViewModel Update(Guid Id, TViewModel data, ProcessDataDelegate <TModel> processDelegate = null)
        {
            var _store = Store;

            if (!ReadMode && _store != null)
            {
                TModel item = (TModel)Activator.CreateInstance(typeof(TModel), new object[] { });
                item.LoadFrom(data);
                _store.Save(item, (x) => {
                    x = processDelegate?.Invoke(x) ?? x;
                    if (CheckHashChange(x))
                    {
                        return(x);
                    }
                    return(null);
                });
                StoreChanges();
                data.LoadFrom(item);
            }
            else if (ReadMode)
            {
                throw new AccessViolationException("Repository is in Read Mode");
            }
            return(data);
        }
示例#2
0
        void ICallback.AddPoints(List <Message> messages)
        {
            ProcessDataDelegate pdt = ProcessData;

            if (pdt != null)
            {
                foreach (Message message in messages)
                {
                    pdt(message.Data1, message.Data2, message.Data3, message.Data4);
                }
            }
        }
示例#3
0
 public SimpleServer(HttpListener listener, string url, ProcessDataDelegate handler)
 {
     this.listener = listener;
     this.handler  = handler;
     listener.Prefixes.Add(url);
 }