2022-02-15 11:52:43 +00:00
|
|
|
namespace ASC.Notify.Messages;
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
public class NoticeMessage : INoticeMessage
|
|
|
|
{
|
|
|
|
[NonSerialized]
|
|
|
|
private readonly List<ITagValue> _arguments = new List<ITagValue>();
|
|
|
|
|
|
|
|
[NonSerialized]
|
|
|
|
private IPattern _pattern;
|
|
|
|
|
|
|
|
public NoticeMessage() { }
|
2022-02-14 21:02:57 +00:00
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
public NoticeMessage(IDirectRecipient recipient, INotifyAction action, string objectID)
|
|
|
|
{
|
|
|
|
Recipient = recipient ?? throw new ArgumentNullException(nameof(recipient));
|
|
|
|
Action = action;
|
|
|
|
ObjectID = objectID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public NoticeMessage(IDirectRecipient recipient, INotifyAction action, string objectID, IPattern pattern)
|
|
|
|
{
|
|
|
|
Recipient = recipient ?? throw new ArgumentNullException(nameof(recipient));
|
|
|
|
Action = action;
|
|
|
|
Pattern = pattern ?? throw new ArgumentNullException(nameof(pattern));
|
|
|
|
ObjectID = objectID;
|
|
|
|
ContentType = pattern.ContentType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public NoticeMessage(IDirectRecipient recipient, string subject, string body, string contentType)
|
|
|
|
{
|
|
|
|
Recipient = recipient ?? throw new ArgumentNullException(nameof(recipient));
|
|
|
|
Subject = subject;
|
|
|
|
Body = body ?? throw new ArgumentNullException(nameof(body));
|
|
|
|
ContentType = contentType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string ObjectID { get; private set; }
|
|
|
|
|
|
|
|
public IDirectRecipient Recipient { get; private set; }
|
|
|
|
|
|
|
|
public IPattern Pattern
|
|
|
|
{
|
|
|
|
get => _pattern;
|
|
|
|
internal set => _pattern = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public INotifyAction Action { get; private set; }
|
|
|
|
|
|
|
|
public ITagValue[] Arguments => _arguments.ToArray();
|
|
|
|
|
|
|
|
public void AddArgument(params ITagValue[] tagValues)
|
|
|
|
{
|
2022-03-09 17:15:51 +00:00
|
|
|
ArgumentNullException.ThrowIfNull(tagValues);
|
|
|
|
|
2022-02-15 11:52:43 +00:00
|
|
|
Array.ForEach(tagValues,
|
|
|
|
tagValue =>
|
|
|
|
{
|
|
|
|
if (!_arguments.Exists(tv => Equals(tv.Tag, tagValue.Tag)))
|
2019-08-15 12:04:42 +00:00
|
|
|
{
|
2022-02-15 11:52:43 +00:00
|
|
|
_arguments.Add(tagValue);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public ITagValue GetArgument(string tag)
|
|
|
|
{
|
|
|
|
return _arguments.Find(r => r.Tag == tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Subject { get; set; }
|
|
|
|
public string Body { get; set; }
|
|
|
|
public string ContentType { get; internal set; }
|
|
|
|
}
|