using System;
using System.Collections.Generic;
using Abp.Application.Features;
using Abp.Authorization;
using Abp.Collections.Extensions;
using Abp.Localization;
namespace Abp.Notifications
{
///
/// Definition for a notification.
///
public class NotificationDefinition
{
///
/// Unique name of the notification.
///
public string Name { get; private set; }
///
/// Related entity type with this notification (optional).
///
public Type EntityType { get; private set; }
///
/// Display name of the notification.
/// Optional.
///
public ILocalizableString DisplayName { get; set; }
///
/// Description for the notification.
/// Optional.
///
public ILocalizableString Description { get; set; }
///
/// A permission dependency. This notification will be available to a user if this dependency is satisfied.
/// Optional.
///
public IPermissionDependency PermissionDependency { get; set; }
///
/// A feature dependency. This notification will be available to a tenant if this feature is enabled.
/// Optional.
///
public IFeatureDependency FeatureDependency { get; set; }
///
/// Gets/sets arbitrary objects related to this object.
/// Gets null if given key does not exists.
/// This is a shortcut for dictionary.
///
/// Key
public object this[string key]
{
get { return Attributes.GetOrDefault(key); }
set { Attributes[key] = value; }
}
///
/// Arbitrary objects related to this object.
/// These objects must be serializable.
///
public IDictionary Attributes { get; private set; }
///
/// Initializes a new instance of the class.
///
/// Unique name of the notification.
/// Related entity type with this notification (optional).
/// Display name of the notification.
/// Description for the notification
/// A permission dependency. This notification will be available to a user if this dependency is satisfied.
/// A feature dependency. This notification will be available to a tenant if this feature is enabled.
public NotificationDefinition(string name, Type entityType = null, ILocalizableString displayName = null, ILocalizableString description = null, IPermissionDependency permissionDependency = null, IFeatureDependency featureDependency = null)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException("name", "name can not be null, empty or whitespace!");
}
Name = name;
EntityType = entityType;
DisplayName = displayName;
Description = description;
PermissionDependency = permissionDependency;
FeatureDependency = featureDependency;
Attributes = new Dictionary();
}
}
}