コード例 #1
0
        public bool TryMove(NotificationSet destination, Enum key)
        {
            var result = false;

            if (destination != null && key != null && Has(key) && !destination.Has(key))
            {
                notifications.Remove(key);
                destination.Add(key);
                result = true;
            }

            return result;
        }
コード例 #2
0
        public void Move(NotificationSet destination, Enum key)
        {
            var logger = ObjectFactory.GetInstance<Logger>();

            if (destination == null)
            {
                logger.Error("[ViewModels].[Application].[NotificationSet].[Move] throwing exception ([destination] == null).");
                throw new ArgumentNullException("destination");
            }

            if (key == null)
            {
                logger.Error("[ViewModels].[Application].[NotificationSet].[Move] throwing exception ([key] == null).");
                throw new ArgumentNullException("key");
            }

            if (!Has(key))
            {
                logger.Error("[ViewModels].[Application].[NotificationSet].[Move] throwing exception ([notifications] does not contains [key]).");
                throw new InvalidOperationException("Source NotificationSet does not has item.");
            }

            if (destination.Has(key))
            {
                logger.Error("[ViewModels].[Application].[NotificationSet].[Move] throwing exception ([destination].[Has] == 'true').");
                throw new InvalidOperationException("Destination NotificationSet already has item.");
            }

            notifications.Remove(key);
            destination.Add(key);
        }