public void Update(A_Card card)
 {
     Rank = card.Rank;
     Suit = card.Suit;
     if (ModelUpdatedEvent != null)
     {
         ModelUpdatedEvent.Invoke();
     }
 }
示例#2
0
        public void Update(int itemId, TModel item, bool invokeEvent = true)
        {
            if (Disposed)
            {
                throw new Exception("Collection is disposed.");
            }

            if (itemId != item.Id)
            {
                if (modelMap.ContainsKey(item.Id))
                {
                    if (modelMap[item.Id].Equals(item))
                    {
                        Remove(item.Id);
                    }
                }
            }

            if (modelMap.ContainsKey(itemId))
            {
                var old = modelMap[itemId];
                modelMap[itemId] = item;

                if (invokeEvent)
                {
                    ModelUpdatedEvent?.Invoke(this, new ModelUpdatedEventArgs()
                    {
                        OldModel     = old,
                        UpdatedModel = item,
                    });
                }
            }
            else
            {
                Add(item, itemId);
            }
        }
示例#3
0
 public Model(ModelUpdatedEvent onModelUpdated)
 {
     OnModelUpdated += onModelUpdated;
     MapperSwitchOffline();
 }