// License: Apache 2.0. See LICENSE file in root directory. // Copyright(c) 2017 Intel Corporation. All Rights Reserved. namespace Intel.RealSense { using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; internal sealed class StreamProfileList : Base.Object, IEnumerable, ICollection { public StreamProfileList(IntPtr ptr) : base(ptr, NativeMethods.rs2_delete_stream_profiles_list) { } /// public IEnumerator GetEnumerator() { object error; int size = NativeMethods.rs2_get_stream_profiles_count(Handle, out error); for (int i = 0; i < size; i++) { var ptr = NativeMethods.rs2_get_stream_profile(Handle, i, out error); yield return StreamProfile.Create(ptr); } } /// IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } /// Gets the number of supported stream profiles /// number of supported subdevice profiles public int Count { get { object error; return NativeMethods.rs2_get_stream_profiles_count(Handle, out error); } } /// public object SyncRoot => this; /// public bool IsSynchronized => false; /// /// Gets a specific stream profile /// /// the zero based index of the streaming mode /// stream profile at given index public StreamProfile this[int index] { get { return GetProfile(index); } } /// /// Gets a specific stream profile /// /// the zero based index of the streaming mode /// type of StreamProfile or a subclass /// stream profile at given index public T GetProfile(int index) where T : StreamProfile { object error; return StreamProfile.Create(NativeMethods.rs2_get_stream_profile(Handle, index, out error)); } /// public void CopyTo(Array array, int index) { if (array == null) { throw new ArgumentNullException("array"); } for (int i = 0; i < Count; i++) { array.SetValue(this[i], i + index); } } } }