Build server prototype (integration with GitHub / NuGet / etc)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
micro-build-server/DotNetBuilder/Messages.cs

45 lines
735 B

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MicroBuildServer.DotNetBuilder
{
internal class Messages
{
private readonly object syncRoot = new object();
private readonly List<Message> storage = new List<Message>();
public void Add(Message message)
{
if (message == null)
{
throw new ArgumentNullException(nameof(message));
}
lock(syncRoot)
{
storage.Add(message);
}
}
public TResult[] ToArray<TResult>(Func<Message, TResult> selector)
{
lock(syncRoot)
{
return storage.Select(selector).ToArray();
}
}
public bool Any()
{
lock(syncRoot)
{
return storage.Any();
}
}
}
}