New test.
[mono.git] / mcs / class / System.Web.Mvc2 / System.Web.Mvc / ViewResult.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.Globalization;\r
16     using System.Text;\r
17     using System.Web.Mvc.Resources;\r
18 \r
19     public class ViewResult : ViewResultBase {\r
20         private string _masterName;\r
21 \r
22         public string MasterName {\r
23             get {\r
24                 return _masterName ?? String.Empty;\r
25             }\r
26             set {\r
27                 _masterName = value;\r
28             }\r
29         }\r
30 \r
31         protected override ViewEngineResult FindView(ControllerContext context) {\r
32             ViewEngineResult result = ViewEngineCollection.FindView(context, ViewName, MasterName);\r
33             if (result.View != null) {\r
34                 return result;\r
35             }\r
36 \r
37             // we need to generate an exception containing all the locations we searched\r
38             StringBuilder locationsText = new StringBuilder();\r
39             foreach (string location in result.SearchedLocations) {\r
40                 locationsText.AppendLine();\r
41                 locationsText.Append(location);\r
42             }\r
43             throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture,\r
44                 MvcResources.Common_ViewNotFound, ViewName, locationsText));\r
45         }\r
46     }\r
47 }\r