New tests.
[mono.git] / mcs / class / System.Web.Mvc2 / System.Web.Mvc / SelectList.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.Collections;\r
15     using System.Diagnostics.CodeAnalysis;    \r
16 \r
17     [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]\r
18     public class SelectList : MultiSelectList {\r
19 \r
20         public SelectList(IEnumerable items)\r
21             : this(items, null /* selectedValue */) {\r
22         }\r
23 \r
24         public SelectList(IEnumerable items, object selectedValue)\r
25             : this(items, null /* dataValuefield */, null /* dataTextField */, selectedValue) {\r
26         }\r
27 \r
28         public SelectList(IEnumerable items, string dataValueField, string dataTextField)\r
29             : this(items, dataValueField, dataTextField, null /* selectedValue */) {\r
30         }\r
31 \r
32         public SelectList(IEnumerable items, string dataValueField, string dataTextField, object selectedValue)\r
33             : base(items, dataValueField, dataTextField, ToEnumerable(selectedValue)) {\r
34             SelectedValue = selectedValue;\r
35         }\r
36 \r
37         public object SelectedValue {\r
38             get;\r
39             private set;\r
40         }\r
41 \r
42         private static IEnumerable ToEnumerable(object selectedValue) {\r
43             return (selectedValue != null) ? new object[] { selectedValue } : null;\r
44         }\r
45     }\r
46 }\r