async Task <IList <int> > StoreAsync(IList <int> indexes, ulong?modseq, IList <Annotation> annotations, bool doAsync, CancellationToken cancellationToken)
{
if (indexes == null)
{
throw new ArgumentNullException(nameof(indexes));
}
if (modseq.HasValue && !SupportsModSeq)
{
throw new NotSupportedException("The ImapFolder does not support mod-sequences.");
}
if (annotations == null)
{
throw new ArgumentNullException(nameof(annotations));
}
CheckState(true, true);
if (AnnotationAccess == AnnotationAccess.None)
{
throw new NotSupportedException("The ImapFolder does not support annotations.");
}
if (indexes.Count == 0 || annotations.Count == 0)
{
return(new int[0]);
}
var set = ImapUtils.FormatIndexSet(indexes);
var builder = new StringBuilder("STORE ");
var values = new List <object> ();
builder.AppendFormat("{0} ", set);
if (modseq.HasValue)
{
builder.AppendFormat(CultureInfo.InvariantCulture, "(UNCHANGEDSINCE {0}) ", modseq.Value);
}
ImapUtils.FormatAnnotations(builder, annotations, values, true);
builder.Append("\r\n");
var command = builder.ToString();
var args = values.ToArray();
var ic = Engine.QueueCommand(cancellationToken, this, command, args);
await Engine.RunAsync(ic, doAsync).ConfigureAwait(false);
ProcessResponseCodes(ic, null);
if (ic.Response != ImapCommandResponse.Ok)
{
throw ImapCommandException.Create("STORE", ic);
}
return(GetUnmodified(ic, modseq));
}