Add collection interfaces to PixelShaderEffect<T>.ResourceTextureManagerCollection

このコミットが含まれているのは:
Sergio Pedri committed 2022-12-22 10:56:03 -08:00
1 親 7cf711cf59
コミット 63799054c1
1ファイル変更
+144 -6
@@ -1,4 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
@@ -7,7 +9,7 @@ using ComputeSharp.D2D1.Interop;
using ComputeSharp.D2D1.Shaders.Loaders;
using ComputeSharp.D2D1.Uwp.Buffers;
#pragma warning disable CS0618
#pragma warning disable CS0618, CS8767
namespace ComputeSharp.D2D1.Uwp;
@@ -17,7 +19,7 @@ partial class PixelShaderEffect<T>
/// <summary>
/// Represents the collection of <see cref="D2D1ResourceTextureManager"/> objects in a <see cref="PixelShaderEffect{T}"/> instance.
/// </summary>
public sealed class ResourceTextureManagerCollection
public sealed class ResourceTextureManagerCollection : IList<D2D1ResourceTextureManager?>, IReadOnlyList<D2D1ResourceTextureManager?>, IList, IFixedCountList<D2D1ResourceTextureManager?>
{
/// <summary>
/// The bitmask of valid indices for resource texture managers in the current shader type.
@@ -38,10 +40,8 @@ partial class PixelShaderEffect<T>
Owner = owner;
}
/// <summary>
/// Gets the collection of valid resource texture indices for the current effect.
/// </summary>
internal static ImmutableArray<int> Indices { get; } = GetIndices();
/// <inheritdoc/>
public int Count => Indices.Length;
/// <summary>
/// Gets or sets the <see cref="D2D1ResourceTextureManager"/> object at a specified index.
@@ -72,6 +72,18 @@ partial class PixelShaderEffect<T>
}
}
/// <inheritdoc/>
object? IList.this[int index]
{
get => this[index];
set => this[index] = (D2D1ResourceTextureManager?)value!;
}
/// <summary>
/// Gets the collection of valid resource texture indices for the current effect.
/// </summary>
internal static ImmutableArray<int> Indices { get; } = GetIndices();
/// <summary>
/// The owning <see cref="PixelShaderEffect{T}"/> instance.
/// </summary>
@@ -82,6 +94,132 @@ partial class PixelShaderEffect<T>
/// </summary>
internal ref ResourceTextureManagerBuffer Storage => ref this.fixedBuffer;
/// <inheritdoc/>
ImmutableArray<int> IFixedCountList<D2D1ResourceTextureManager?>.Indices => Indices;
/// <inheritdoc/>
bool ICollection<D2D1ResourceTextureManager?>.IsReadOnly => false;
/// <inheritdoc/>
bool IList.IsReadOnly => false;
/// <inheritdoc/>
bool IList.IsFixedSize => true;
/// <inheritdoc/>
bool ICollection.IsSynchronized => true;
/// <inheritdoc/>
object ICollection.SyncRoot => throw new NotSupportedException("ICollection.SyncRoot is not supported for ResourceTextureManagerCollection.");
/// <inheritdoc/>
void ICollection<D2D1ResourceTextureManager?>.Add(D2D1ResourceTextureManager? item)
{
throw new NotSupportedException("ICollection<T>.Add is not supported for ResourceTextureManagerCollection.");
}
/// <inheritdoc/>
int IList.Add(object value)
{
throw new NotSupportedException("IList.Add is not supported for ResourceTextureManagerCollection.");
}
/// <inheritdoc/>
void ICollection<D2D1ResourceTextureManager?>.Clear()
{
throw new NotSupportedException("ICollection<T>.Clear is not supported for ResourceTextureManagerCollection.");
}
/// <inheritdoc/>
void IList.Clear()
{
throw new NotSupportedException("IList.Clear is not supported for ResourceTextureManagerCollection.");
}
/// <inheritdoc/>
bool ICollection<D2D1ResourceTextureManager?>.Contains(D2D1ResourceTextureManager? item)
{
return FixedCountList<D2D1ResourceTextureManager?>.IndexOf(this, item) != -1;
}
/// <inheritdoc/>
bool IList.Contains(object value)
{
return FixedCountList<D2D1ResourceTextureManager?>.IndexOf(this, (D2D1ResourceTextureManager?)value) != -1;
}
/// <inheritdoc/>
void ICollection<D2D1ResourceTextureManager?>.CopyTo(D2D1ResourceTextureManager?[] array, int arrayIndex)
{
FixedCountList<D2D1ResourceTextureManager?>.CopyTo(this, array, arrayIndex);
}
/// <inheritdoc/>
void ICollection.CopyTo(Array array, int index)
{
FixedCountList<D2D1ResourceTextureManager?>.CopyTo(this, array, index);
}
/// <inheritdoc/>
IEnumerator<D2D1ResourceTextureManager?> IEnumerable<D2D1ResourceTextureManager?>.GetEnumerator()
{
return FixedCountList<D2D1ResourceTextureManager?>.GetEnumerator(this);
}
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator()
{
return FixedCountList<D2D1ResourceTextureManager?>.GetEnumerator(this);
}
/// <inheritdoc/>
int IList<D2D1ResourceTextureManager?>.IndexOf(D2D1ResourceTextureManager? item)
{
return FixedCountList<D2D1ResourceTextureManager?>.IndexOf(this, item);
}
/// <inheritdoc/>
int IList.IndexOf(object value)
{
return FixedCountList<D2D1ResourceTextureManager?>.IndexOf(this, (D2D1ResourceTextureManager?)value);
}
/// <inheritdoc/>
void IList<D2D1ResourceTextureManager?>.Insert(int index, D2D1ResourceTextureManager? item)
{
throw new NotSupportedException("IList<T>.Insert is not supported for ResourceTextureManagerCollection.");
}
/// <inheritdoc/>
void IList.Insert(int index, object value)
{
throw new NotSupportedException("IList.Insert is not supported for ResourceTextureManagerCollection.");
}
/// <inheritdoc/>
bool ICollection<D2D1ResourceTextureManager?>.Remove(D2D1ResourceTextureManager? item)
{
throw new NotSupportedException("ICollection<T>.Remove is not supported for ResourceTextureManagerCollection.");
}
/// <inheritdoc/>
void IList.Remove(object value)
{
throw new NotSupportedException("IList.Remove is not supported for ResourceTextureManagerCollection.");
}
/// <inheritdoc/>
void IList<D2D1ResourceTextureManager?>.RemoveAt(int index)
{
throw new NotSupportedException("IList<T>.RemoveAt is not supported for ResourceTextureManagerCollection.");
}
/// <inheritdoc/>
void IList.RemoveAt(int index)
{
throw new NotSupportedException("IList.RemoveAt is not supported for ResourceTextureManagerCollection.");
}
/// <summary>
/// Validates the input index for <see cref="this[int]"/>.
/// </summary>