Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System / compmod / system / codedom / compiler / CompilerErrorCollection.cs
1 // ------------------------------------------------------------------------------
2 // <copyright file="CompilerErrorCollection.cs" company="Microsoft">
3 // 
4 // <OWNER>[....]</OWNER>
5 //     Copyright (c) Microsoft Corporation.  All rights reserved.
6 // </copyright> 
7 // ------------------------------------------------------------------------------
8 // 
9 namespace System.CodeDom.Compiler {
10     using System;
11     using System.Collections;
12     using System.Security.Permissions;
13     
14     
15     /// <devdoc>
16     ///     <para>
17     ///       A collection that stores <see cref='System.CodeDom.Compiler.CompilerError'/> objects.
18     ///    </para>
19     /// </devdoc>
20     [Serializable()]
21     [PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")]
22     public class CompilerErrorCollection : CollectionBase {
23         
24         /// <devdoc>
25         ///     <para>
26         ///       Initializes a new instance of <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/>.
27         ///    </para>
28         /// </devdoc>
29         public CompilerErrorCollection() {
30         }
31         
32         /// <devdoc>
33         ///     <para>
34         ///       Initializes a new instance of <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/> based on another <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/>.
35         ///    </para>
36         /// </devdoc>
37         public CompilerErrorCollection(CompilerErrorCollection value) {
38             this.AddRange(value);
39         }
40         
41         /// <devdoc>
42         ///     <para>
43         ///       Initializes a new instance of <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/> containing any array of <see cref='System.CodeDom.Compiler.CompilerError'/> objects.
44         ///    </para>
45         /// </devdoc>
46         public CompilerErrorCollection(CompilerError[] value) {
47             this.AddRange(value);
48         }
49         
50         /// <devdoc>
51         /// <para>Represents the entry at the specified index of the <see cref='System.CodeDom.Compiler.CompilerError'/>.</para>
52         /// </devdoc>
53         public CompilerError this[int index] {
54             get {
55                 return ((CompilerError)(List[index]));
56             }
57             set {
58                 List[index] = value;
59             }
60         }
61         
62         /// <devdoc>
63         ///    <para>Adds a <see cref='System.CodeDom.Compiler.CompilerError'/> with the specified value to the 
64         ///    <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/> .</para>
65         /// </devdoc>
66         public int Add(CompilerError value) {
67             return List.Add(value);
68         }
69         
70         /// <devdoc>
71         /// <para>Copies the elements of an array to the end of the <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/>.</para>
72         /// </devdoc>
73         public void AddRange(CompilerError[] value) {
74             if (value == null) {
75                 throw new ArgumentNullException("value");
76             }
77             for (int i = 0; ((i) < (value.Length)); i = ((i) + (1))) {
78                 this.Add(value[i]);
79             }
80         }
81         
82         /// <devdoc>
83         ///     <para>
84         ///       Adds the contents of another <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/> to the end of the collection.
85         ///    </para>
86         /// </devdoc>
87         public void AddRange(CompilerErrorCollection value) {
88             if (value == null) {
89                 throw new ArgumentNullException("value");
90             }
91             int currentCount = value.Count;
92             for (int i = 0; i < currentCount; i = ((i) + (1))) {
93                 this.Add(value[i]);
94             }
95         }
96         
97         /// <devdoc>
98         /// <para>Gets a value indicating whether the 
99         ///    <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/> contains the specified <see cref='System.CodeDom.Compiler.CompilerError'/>.</para>
100         /// </devdoc>
101         public bool Contains(CompilerError value) {
102             return List.Contains(value);
103         }
104         
105         /// <devdoc>
106         /// <para>Copies the <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/> values to a one-dimensional <see cref='System.Array'/> instance at the 
107         ///    specified index.</para>
108         /// </devdoc>
109         public void CopyTo(CompilerError[] array, int index) {
110             List.CopyTo(array, index);
111         }
112
113         /// <devdoc>
114         ///    <para>
115         ///       Gets or sets
116         ///       a value indicating whether the collection contains errors.
117         ///    </para>
118         /// </devdoc>
119         public bool HasErrors {
120             get {
121                 if (Count > 0) {
122                     foreach (CompilerError e in this) {
123                         if (!e.IsWarning) {
124                             return true;
125                         }
126                     }
127                 }
128                 return false;
129             }
130         }
131
132         /// <devdoc>
133         ///    <para>
134         ///       Gets or sets
135         ///       a value indicating whether the collection contains warnings.
136         ///    </para>
137         /// </devdoc>
138         public bool HasWarnings {
139             get {
140                 if (Count > 0) {
141                     foreach (CompilerError e in this) {
142                         if (e.IsWarning) {
143                             return true;
144                         }
145                     }
146                 }
147                 return false;
148             }
149         }
150         
151         /// <devdoc>
152         ///    <para>Returns the index of a <see cref='System.CodeDom.Compiler.CompilerError'/> in 
153         ///       the <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/> .</para>
154         /// </devdoc>
155         public int IndexOf(CompilerError value) {
156             return List.IndexOf(value);
157         }
158         
159         /// <devdoc>
160         /// <para>Inserts a <see cref='System.CodeDom.Compiler.CompilerError'/> into the <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/> at the specified index.</para>
161         /// </devdoc>
162         public void Insert(int index, CompilerError value) {
163             List.Insert(index, value);
164         }
165         
166         /// <devdoc>
167         ///    <para> Removes a specific <see cref='System.CodeDom.Compiler.CompilerError'/> from the 
168         ///    <see cref='System.CodeDom.Compiler.CompilerErrorCollection'/> .</para>
169         /// </devdoc>
170         public void Remove(CompilerError value) {
171             List.Remove(value);
172         }
173     }
174 }