[Multimedia.Util] Modified to throw NotSupportedException for NotSupported error...
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Util / ImageUtil / ImageTransformCollection.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Collections;
19 using System.Collections.Generic;
20
21 namespace Tizen.Multimedia.Util
22 {
23     /// <summary>
24     /// Represents a collection of <see cref="ImageTransform"/> objects that can be individually accessed by index.
25     /// </summary>
26     /// <since_tizen> 4 </since_tizen>
27     public class ImageTransformCollection : IEnumerable<ImageTransform>, IList<ImageTransform>
28     {
29         private List<ImageTransform> _list = new List<ImageTransform>();
30
31         /// <summary>
32         /// Initializes a new instance of the ImageTransformCollection class.
33         /// </summary>
34         /// <since_tizen> 4 </since_tizen>
35         public ImageTransformCollection()
36         {
37         }
38
39         /// <summary>
40         /// Gets or sets the <see cref="ImageTransform"/> at the specified index.
41         /// </summary>
42         /// <param name="index">The zero-based index of the <see cref="ImageTransform"/> to get or set.</param>
43         /// <value>The <see cref="ImageTransform"/> at the specified index.</value>
44         /// <exception cref="ArgumentOutOfRangeException">
45         ///     index is less than 0.<br/>
46         ///     -or-<br/>
47         ///     index is equal to or greater than <see cref="Count"/>.
48         /// </exception>
49         /// <since_tizen> 4 </since_tizen>
50         public ImageTransform this[int index]
51         {
52             get { return _list[index]; }
53             set { _list[index] = value; }
54         }
55
56         /// <summary>
57         /// Gets the number of items contained in the TransformCollection.
58         /// </summary>
59         /// <since_tizen> 4 </since_tizen>
60         public int Count => _list.Count;
61
62         bool ICollection<ImageTransform>.IsReadOnly => false;
63
64         /// <summary>
65         /// Adds a <see cref="ImageTransform"/> to the end of the collection.
66         /// </summary>
67         /// <param name="item">The <see cref="ImageTransform"/> to add.</param>
68         /// <remarks>
69         /// <see cref="ImageTransformCollection"/> accepts null as a valid value for reference types and allows duplicate elements.
70         /// </remarks>
71         /// <since_tizen> 4 </since_tizen>
72         public void Add(ImageTransform item)
73         {
74             if (item == null)
75             {
76                 throw new ArgumentNullException(nameof(item));
77             }
78             _list.Add(item);
79         }
80
81         /// <summary>
82         /// Removes all items.
83         /// </summary>
84         /// <since_tizen> 4 </since_tizen>
85         public void Clear() => _list.Clear();
86
87         /// <summary>
88         /// Determines whether the <see cref="ImageTransformCollection"/> contains the specified item.
89         /// </summary>
90         /// <param name="item">The <see cref="ImageTransform"/> to locate in the collection.</param>
91         /// <returns>true if the <see cref="ImageTransform"/> is found in the collection; otherwise, false.</returns>
92         /// <since_tizen> 4 </since_tizen>
93         public bool Contains(ImageTransform item) => _list.Contains(item);
94
95         /// <summary>
96         /// Copies the items of the collection to an array, starting at the specified array index.
97         /// </summary>
98         /// <param name="array">The one-dimensional array that is the destination of the items copied from the collection.</param>
99         /// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
100         /// <exception cref="ArgumentNullException"><paramref name="array"/> is null.</exception>
101         /// <exception cref="ArgumentOutOfRangeException"><paramref name="arrayIndex"/> is less than 0.</exception>
102         /// <exception cref="ArgumentException">
103         /// The number of elements in the source collection is greater than the available space from arrayIndex to the end of the destination array.
104         /// </exception>
105         /// <since_tizen> 4 </since_tizen>
106         public void CopyTo(ImageTransform[] array, int arrayIndex) => _list.CopyTo(array, arrayIndex);
107
108         /// <summary>
109         /// Determines the index of the specified item in the collection.
110         /// </summary>
111         /// <param name="item">The <see cref="ImageTransform"/> to locate in the collection.</param>
112         /// <returns>The index of value if found in the <see cref="ImageTransformCollection"/>; otherwise, -1.</returns>
113         /// <since_tizen> 4 </since_tizen>
114         public int IndexOf(ImageTransform item) => _list.IndexOf(item);
115
116         /// <summary>
117         /// Inserts a <see cref="ImageTransform"/> into the collection at the specified index.
118         /// </summary>
119         /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
120         /// <param name="item">The <see cref="ImageTransform"/> to insert into the collection.</param>
121         /// <exception cref="ArgumentNullException"><paramref name="item"/> is null.</exception>
122         /// <exception cref="ArgumentOutOfRangeException">
123         ///     index is less than 0.<br/>
124         ///     -or-<br/>
125         ///     index is greater than <see cref="Count"/>.
126         /// </exception>
127         /// <since_tizen> 4 </since_tizen>
128         public void Insert(int index, ImageTransform item)
129         {
130             if (item == null)
131             {
132                 throw new ArgumentNullException(nameof(item));
133             }
134             _list.Insert(index, item);
135         }
136
137         /// <summary>
138         /// Removes the first occurrence of the specified <see cref="ImageTransform"/> from the collection.
139         /// </summary>
140         /// <param name="item">The <see cref="ImageTransform"/> to remove.</param>
141         /// <returns>true if <paramref name="item"/> was removed from the collection; otherwise, false.</returns>
142         /// <since_tizen> 4 </since_tizen>
143         public bool Remove(ImageTransform item) => _list.Remove(item);
144
145         /// <summary>
146         /// Removes the <see cref="ImageTransform"/> at the specified index.
147         /// </summary>
148         /// <param name="index">The zero-based index to remove.</param>
149         /// <exception cref="ArgumentOutOfRangeException">
150         ///     index is less than 0.<br/>
151         ///     -or-<br/>
152         ///     index is equal to or greater than <see cref="Count"/>.
153         /// </exception>
154         /// <since_tizen> 4 </since_tizen>
155         public void RemoveAt(int index) => _list.RemoveAt(index);
156
157         /// <summary>
158         /// Returns an enumerator that can iterate through the collection.
159         /// </summary>
160         /// <returns>An enumerator that can be used to iterate through the collection.</returns>
161         /// <since_tizen> 4 </since_tizen>
162         public IEnumerator<ImageTransform> GetEnumerator() => _list.GetEnumerator();
163
164         IEnumerator IEnumerable.GetEnumerator() => _list.GetEnumerator();
165     }
166 }