using System; using System.Collections; using System.Collections.Generic; namespace Content.Server.PDA { public sealed class PDAAccessSet : ISet { private readonly PDAComponent _pdaComponent; private static readonly HashSet EmptySet = new(); public PDAAccessSet(PDAComponent pdaComponent) { _pdaComponent = pdaComponent; } public IEnumerator GetEnumerator() { var contained = _pdaComponent.GetContainedAccess() ?? EmptySet; return contained.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } void ICollection.Add(string item) { throw new NotSupportedException("PDA access list is read-only."); } public void ExceptWith(IEnumerable other) { throw new NotSupportedException("PDA access list is read-only."); } public void IntersectWith(IEnumerable other) { throw new NotSupportedException("PDA access list is read-only."); } public bool IsProperSubsetOf(IEnumerable other) { var set = _pdaComponent.GetContainedAccess() ?? EmptySet; return set.IsProperSubsetOf(other); } public bool IsProperSupersetOf(IEnumerable other) { var set = _pdaComponent.GetContainedAccess() ?? EmptySet; return set.IsProperSupersetOf(other); } public bool IsSubsetOf(IEnumerable other) { var set = _pdaComponent.GetContainedAccess() ?? EmptySet; return set.IsSubsetOf(other); } public bool IsSupersetOf(IEnumerable other) { var set = _pdaComponent.GetContainedAccess() ?? EmptySet; return set.IsSupersetOf(other); } public bool Overlaps(IEnumerable other) { var set = _pdaComponent.GetContainedAccess() ?? EmptySet; return set.Overlaps(other); } public bool SetEquals(IEnumerable other) { var set = _pdaComponent.GetContainedAccess() ?? EmptySet; return set.SetEquals(other); } public void SymmetricExceptWith(IEnumerable other) { throw new NotSupportedException("PDA access list is read-only."); } public void UnionWith(IEnumerable other) { throw new NotSupportedException("PDA access list is read-only."); } bool ISet.Add(string item) { throw new NotSupportedException("PDA access list is read-only."); } public void Clear() { throw new NotSupportedException("PDA access list is read-only."); } public bool Contains(string item) { return _pdaComponent.GetContainedAccess()?.Contains(item) ?? false; } public void CopyTo(string[] array, int arrayIndex) { var set = _pdaComponent.GetContainedAccess() ?? EmptySet; set.CopyTo(array, arrayIndex); } public bool Remove(string item) { throw new NotSupportedException("PDA access list is read-only."); } public int Count => _pdaComponent.GetContainedAccess()?.Count ?? 0; public bool IsReadOnly => true; } }