Ejemplo n.º 1
0
 public static TEntity Add <TKey, TEntity>(this IAtomicWriter <TKey, TEntity> self, TKey key, TEntity newEntity)
 {
     return(self.AddOrUpdate(key, newEntity, e =>
     {
         var txt = String.Format("Entity '{0}' with key '{1}' should not exist.", typeof(TEntity).Name, key);
         throw new InvalidOperationException(txt);
     }, AddOrUpdateHint.ProbablyDoesNotExist));
 }
 public static TView UpdateOrThrow <TKey, TView>(this IAtomicWriter <TKey, TView> self, TKey key, Func <TView, TView> change)
 {
     return(self.AddOrUpdate(key, () =>
     {
         var txt = String.Format("Failed to load '{0}' with key '{1}'.", typeof(TView).Name, key);
         throw new InvalidOperationException(txt);
     }, change));
 }
Ejemplo n.º 3
0
 public static TEntity UpdateOrThrow <TKey, TEntity>(this IAtomicWriter <TKey, TEntity> self, TKey key, Action <TEntity> change)
 {
     return(self.AddOrUpdate(key, () =>
     {
         var txt = String.Format("Failed to load '{0}' with key '{1}'.", typeof(TEntity).Name, key);
         throw new InvalidOperationException(txt);
     }, change, AddOrUpdateHint.ProbablyExists));
 }
 public static TView UpdateOrThrow <TKey, TView>(this IAtomicWriter <TKey, TView> self, TKey key, Action <TView> update)
 {
     return(self.UpdateOrThrow(key, view =>
     {
         update(view);
         return view;
     }));
 }
 public static TView Add <TKey, TView>(this IAtomicWriter <TKey, TView> self, TKey key, TView newView)
 {
     return(self.AddOrUpdate(key, () => newView, view =>
     {
         var txt = String.Format("View '{0}' with key '{1}' should not exist.", typeof(TView).Name, key);
         throw new InvalidOperationException(txt);
     }));
 }
Ejemplo n.º 6
0
 public static TEntity AddOrUpdate <TKey, TEntity>(this IAtomicWriter <TKey, TEntity> self, TKey key, TEntity newView, Action <TEntity> updateViewFactory, AddOrUpdateHint hint = AddOrUpdateHint.ProbablyExists)
 {
     return(self.AddOrUpdate(key, () => newView, view =>
     {
         updateViewFactory(view);
         return view;
     }, hint));
 }
Ejemplo n.º 7
0
 public static TEntity AddOrUpdate <TKey, TEntity>(this IAtomicWriter <TKey, TEntity> self, TKey key, Func <TEntity> addFactory, Action <TEntity> update, AddOrUpdateHint hint = AddOrUpdateHint.ProbablyExists)
 {
     return(self.AddOrUpdate(key, addFactory, entity =>
     {
         update(entity);
         return entity;
     }, hint));
 }
 protected static void HandleAtomic(AtomicMessage msg, SimpleMessageSender sender, IAtomicWriter<unit, int> arg3)
 {
     var count = arg3.AddOrUpdate(unit.it, () => 1, i => i + 1);
     if (count > 2)
     {
         sender.SendBatch(new object[] {}, e => e.AddString("ok"));
         return;
     }
     sender.SendOne(new AtomicMessage());
 }
Ejemplo n.º 9
0
 public static TView UpdateEnforcingNew <TKey, TView>(this IAtomicWriter <TKey, TView> self, TKey key,
                                                      Action <TView> update, AddOrUpdateHint hint = AddOrUpdateHint.ProbablyExists)
     where TView : new()
 {
     return(self.AddOrUpdate(key, () =>
     {
         var view = new TView();
         update(view);
         return view;
     }, v =>
     {
         update(v);
         return v;
     }, hint));
 }
Ejemplo n.º 10
0
        private static void MouseClickHandler(ImmutableEnvelope envelope, IAtomicWriter <unit, PointsView> writer)
        {
            var mouseMovedEvent = (MouseClick)envelope.Items[0].Content;

            writer.AddOrUpdate(unit.it, () => new PointsView(),
                               v =>
            {
                var Point = v.Points.FirstOrDefault(p => p.X == mouseMovedEvent.X && p.Y == mouseMovedEvent.Y);
                if (Point != null)
                {
                    Point.Intensity += 10;
                }
                else
                {
                    v.Points.Add(new HeatPoint(mouseMovedEvent.X, mouseMovedEvent.Y, 50));
                }
            });
        }
 public RecipeByNameIndexProjection(IAtomicWriter <unit, RecipeByNameIndex> writer)
 {
     this.writer = writer;
 }
 public RecipeByNameIndexProjection(IAtomicWriter<unit, RecipeByNameIndex> writer)
 {
     this.writer = writer;
 }
Ejemplo n.º 13
0
 public AccountLoginsProjection(IAtomicWriter <SecurityId, AccountLoginsView> writer)
 {
     _writer = writer;
 }
 public CustomerEventListener(IAtomicWriter <string, CustomerViewModel> writer)
 {
     _writer = writer;
 }
Ejemplo n.º 15
0
 public SecurityProjection(IAtomicWriter<SecurityId, SecurityView> writer)
 {
     _writer = writer;
 }
 public TaskDetailsProjection(IAtomicWriter <TaskId, TaskDetailsView> writer)
 {
     this.writer = writer;
 }
Ejemplo n.º 17
0
 public TaskProjection(IAtomicWriter <TaskView> writer)
 {
     this.writer = writer;
 }
Ejemplo n.º 18
0
        private static void MouseClickHandler(ImmutableEnvelope envelope, IAtomicWriter<unit, PointsView> writer)
        {
            var mouseMovedEvent = (MouseClick)envelope.Items[0].Content;

            writer.AddOrUpdate(unit.it, () => new PointsView(),
                v =>
                {
                    var Point = v.Points.FirstOrDefault(p => p.X == mouseMovedEvent.X && p.Y == mouseMovedEvent.Y);
                    if (Point != null)
                    {
                        Point.Intensity += 10;
                    }
                    else
                    {
                        v.Points.Add(new HeatPoint(mouseMovedEvent.X, mouseMovedEvent.Y, 50));
                    }
                });
        }
Ejemplo n.º 19
0
 public static void Update <TItem>(this IAtomicWriter <TItem> writer, int key, Func <TItem, TItem> update) where TItem : class
 {
     writer.AddOrUpdate(key, null, update);
 }
Ejemplo n.º 20
0
        protected static void HandleAtomic(AtomicMessage msg, SimpleMessageSender sender, IAtomicWriter <unit, int> arg3)
        {
            var count = arg3.AddOrUpdate(unit.it, () => 1, i => i + 1);

            if (count > 2)
            {
                sender.SendBatch(new object[] {}, e => e.AddString("ok"));
                return;
            }
            sender.SendOne(new AtomicMessage());
        }
Ejemplo n.º 21
0
 public LoginViewProjection(IAtomicWriter <UserId, LoginView> writer)
 {
     _writer = writer;
 }
 public TaskDetailsProjection(IAtomicWriter<TaskId, TaskDetailsView> writer)
 {
     this.writer = writer;
 }
Ejemplo n.º 23
0
 public LoginsIndexProjection(IAtomicWriter <unit, LoginsIndexView> writer)
 {
     _writer = writer;
 }
Ejemplo n.º 24
0
 public LoginsIndexProjection(IAtomicWriter<unit, LoginsIndexView> writer)
 {
     _writer = writer;
 }
Ejemplo n.º 25
0
 public SecurityProjection(IAtomicWriter <SecurityId, SecurityView> writer)
 {
     _writer = writer;
 }
Ejemplo n.º 26
0
 public LoginViewProjection(IAtomicWriter<UserId, LoginView> writer)
 {
     _writer = writer;
 }
 public AccountLoginsProjection(IAtomicWriter<SecurityId, AccountLoginsView> writer)
 {
     _writer = writer;
 }
 public RecipeProjection(IAtomicWriter<RecipeId, RecipeView> writer)
 {
     this.writer = writer;
 }
 public RecipeProjection(IAtomicWriter <RecipeId, RecipeView> writer)
 {
     this.writer = writer;
 }
Ejemplo n.º 30
0
 public HeatMapGenerateTask(IAtomicReader <unit, PointsView> reader, IAtomicWriter <unit, HeatMapView> mapWriter)
 {
     _reader    = reader;
     _mapWriter = mapWriter;
 }
Ejemplo n.º 31
0
 public static void Add <TItem>(this IAtomicWriter <TItem> writer, int key, Func <TItem> addFactory) where TItem : class
 {
     writer.AddOrUpdate(key, addFactory, null, false);
 }
Ejemplo n.º 32
0
 public TaskProjection(IAtomicWriter<TaskView> writer)
 {
     this.writer = writer;
 }