public void Add(Enum key) { var logger = ObjectFactory.GetInstance<Logger>(); if (key == null) { logger.Error("[ViewModels].[Application].[NotificationSet].[Add] throwing exception ([key] == null)."); throw new ArgumentNullException("key"); } if (notifications.Contains(key)) { logger.Error("[ViewModels].[Application].[NotificationSet].[Add] throwing exception ([notifications] already contains [key])."); throw new ArgumentException("NotificationSet already contains this notification.", "key"); } var attribute = key.TryGetAttribute<NotificationAttribute>(); if (attribute == null) { logger.Error("[ViewModels].[Application].[NotificationSet].[Add] throwing exception ([attribute] == null)."); throw new ArgumentException("Item does not has NotificationAttribute.", "key"); } notifications.Add(key); }
public bool TryAdd(Enum key) { var result = false; if (key != null && !notifications.Contains(key)) { var attribute = key.TryGetAttribute<NotificationAttribute>(); if (attribute != null) { notifications.Add(key); result = true; } } return result; }
public NotificationItem TryGet(Enum key) { NotificationItem result = null; if (key != null && notifications.Contains(key)) { var attribute = key.TryGetAttribute<NotificationAttribute>(); if (attribute != null) { result = new NotificationItem(attribute.Message, attribute.Type); } } return result; }
public NotificationItem Get(Enum key) { var logger = ObjectFactory.GetInstance<Logger>(); if (key == null) { logger.Error("[ViewModels].[Application].[NotificationSet].[Get] throwing exception ([key] == null)."); throw new ArgumentNullException("key"); } if (!notifications.Contains(key)) { logger.Error("[ViewModels].[Application].[NotificationSet].[Get] throwing exception ([notifications] does not contains [key])."); throw new ArgumentException("NotificationSet does not contains this notification.", "key"); } var attribute = key.TryGetAttribute<NotificationAttribute>(); if (attribute == null) { logger.Error("[ViewModels].[Application].[NotificationSet].[Get] throwing exception ([attribute] == null)."); throw new ArgumentException("Item does not has NotificationAttribute.", "key"); } return new NotificationItem(attribute.Message, attribute.Type); }