// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.AspNet.SignalR.Messaging
{
///
///
///
[SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes", Justification = "Messages are never compared")]
public struct MessageResult
{
private static readonly List> _emptyList = new List>();
public readonly static MessageResult TerminalMessage = new MessageResult(terminal: true);
///
/// Gets an associated with the result.
///
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an optimization to avoid allocations.")]
public IList> Messages { get; private set; }
public int TotalCount { get; private set; }
public bool Terminal { get; set; }
public MessageResult(bool terminal)
: this(_emptyList, 0)
{
Terminal = terminal;
}
///
/// Initializes a new instance of the struct.
///
/// The array of messages associated with this .
/// The amount of messages populated in the messages array.
public MessageResult(IList> messages, int totalCount)
: this()
{
Messages = messages;
TotalCount = totalCount;
}
}
}