Merge pull request #5766 from RoosterDragon/read-only-frames

Make sprite frames read-only lists.
This commit is contained in:
Paul Chote
2014-06-28 21:54:30 +12:00
12 changed files with 248 additions and 238 deletions

View File

@@ -21,12 +21,20 @@ namespace OpenRA
/// duplicate it but provide a compatible interface that can be replaced
/// when we switch to .NET 4.5 or higher.
/// </remarks>
public interface IReadOnlyList<T> : IEnumerable<T>
public interface IReadOnlyList<out T> : IEnumerable<T>
{
int Count { get; }
T this[int index] { get; }
}
public static class ReadOnlyList
{
public static IReadOnlyList<T> AsReadOnly<T>(this IList<T> list)
{
return list as IReadOnlyList<T> ?? new ReadOnlyList<T>(list);
}
}
/// <summary>
/// A minimal read only list for .NET 4 implemented as a wrapper
/// around an IList.