using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Diagnostics.CodeAnalysis;
namespace MT.Platform.Common
{
///
/// Subscription base class. Contains notification "type" and notification message filters.
///
public abstract class Subscription
{
private object lockObject = new object();
///
/// Lock for ensuring thread safety of subscriptions.
///
protected object LockObject { get { return lockObject; } }
///
/// Constructor
///
/// type of notification this subscriber is interested to receive
/// notification message filter defining rules for filter in or out of messages
protected Subscription(Type notificationType, IList filters)
{
lock (lockObject)
{
this.notificationType = notificationType;
this.filters = filters;
}
}
private Type notificationType = null;
///
/// Notification type. Type.Missing means to subscribe for any type of notification.
///
public Type NotificationType
{
get { return notificationType; }
}
private IList filters;
///
/// List of notification message filters. Depending on the notification's content it is sent or not.
/// Allows for more fine-grained control over notification subscriptions and who gets which notifications.
///
public IList Filters
{
get { return filters; }
}
///
/// Indicates whether subscription is local or remote.
///
public virtual NotificationScope Scope { get { return NotificationScope.Local; } }
///
/// Send notification using this subscriber type.
///
///
[SuppressMessage("Microsoft.Design", "CA1030", Justification="there are no events in a WCF contract")]
public abstract void Send(Notification notification);
}
}