Fix bugs in sizing TableLayoutPanel (Xamarin bug 18638)
[mono.git] / mcs / class / System.Web.Mvc2 / System.Web.Mvc / ValueProviderCollection.cs
1 /* ****************************************************************************\r
2  *\r
3  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4  *\r
5  * This software is subject to the Microsoft Public License (Ms-PL). \r
6  * A copy of the license can be found in the license.htm file included \r
7  * in this distribution.\r
8  *\r
9  * You must not remove this notice, or any other, from this software.\r
10  *\r
11  * ***************************************************************************/\r
12 \r
13 namespace System.Web.Mvc {\r
14     using System;\r
15     using System.Collections.Generic;\r
16     using System.Collections.ObjectModel;\r
17     using System.Linq;\r
18 \r
19     public class ValueProviderCollection : Collection<IValueProvider>, IValueProvider {\r
20 \r
21         public ValueProviderCollection() {\r
22         }\r
23 \r
24         public ValueProviderCollection(IList<IValueProvider> list)\r
25             : base(list) {\r
26         }\r
27 \r
28         public virtual bool ContainsPrefix(string prefix) {\r
29             return this.Any(vp => vp.ContainsPrefix(prefix));\r
30         }\r
31 \r
32         public virtual ValueProviderResult GetValue(string key) {\r
33             return (from provider in this\r
34                     let result = provider.GetValue(key)\r
35                     where result != null\r
36                     select result).FirstOrDefault();\r
37         }\r
38 \r
39         protected override void InsertItem(int index, IValueProvider item) {\r
40             if (item == null) {\r
41                 throw new ArgumentNullException("item");\r
42             }\r
43             base.InsertItem(index, item);\r
44         }\r
45 \r
46         protected override void SetItem(int index, IValueProvider item) {\r
47             if (item == null) {\r
48                 throw new ArgumentNullException("item");\r
49             }\r
50             base.SetItem(index, item);\r
51         }\r
52 \r
53     }\r
54 }\r