using System; using System.Collections.Generic; using Abp.Collections.Extensions; using Abp.Json; namespace Abp.Notifications { /// /// Used to store data for a notification. /// It can be directly used or can be derived. /// [Serializable] public class NotificationData { /// /// Gets notification data type name. /// It returns the full class name by default. /// public virtual string Type => GetType().FullName; /// /// Shortcut to set/get . /// public object this[string key] { get { return Properties.GetOrDefault(key); } set { Properties[key] = value; } } /// /// Can be used to add custom properties to this notification. /// public Dictionary Properties { get { return _properties; } set { if (value == null) { throw new ArgumentNullException(nameof(value)); } /* Not assign value, but add dictionary items. This is required for backward compability. */ foreach (var keyValue in value) { if (!_properties.ContainsKey(keyValue.Key)) { _properties[keyValue.Key] = keyValue.Value; } } } } private readonly Dictionary _properties; /// /// Createa a new NotificationData object. /// public NotificationData() { _properties = new Dictionary(); } public override string ToString() { return this.ToJsonString(); } } }