New tests.
[mono.git] / mcs / class / System.Web.Mvc2 / System.Web.Mvc / PartialViewResult.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 PartialViewResult : ViewResultBase {\r
20 \r
21         protected override ViewEngineResult FindView(ControllerContext context) {\r
22             ViewEngineResult result = ViewEngineCollection.FindPartialView(context, ViewName);\r
23             if (result.View != null) {\r
24                 return result;\r
25             }\r
26 \r
27             // we need to generate an exception containing all the locations we searched\r
28             StringBuilder locationsText = new StringBuilder();\r
29             foreach (string location in result.SearchedLocations) {\r
30                 locationsText.AppendLine();\r
31                 locationsText.Append(location);\r
32             }\r
33             throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture,\r
34                 MvcResources.Common_PartialViewNotFound, ViewName, locationsText));\r
35         }\r
36     }\r
37 }\r