New tests.
[mono.git] / mcs / class / System.Web.Mvc2 / System.Web.Mvc / BuildManagerWrapper.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.IO;\r
16     using System.Web.Compilation;\r
17 \r
18     internal sealed class BuildManagerWrapper : IBuildManager {\r
19         private static readonly Func<string, Stream> _readCachedFileDelegate =\r
20             TypeHelpers.CreateDelegate<Func<string, Stream>>(typeof(BuildManager), "ReadCachedFile", null /* thisParameter */);\r
21         private static readonly Func<string, Stream> _createCachedFileDelegate =\r
22             TypeHelpers.CreateDelegate<Func<string, Stream>>(typeof(BuildManager), "CreateCachedFile", null /* thisParameter */);\r
23 \r
24         #region IBuildManager Members\r
25         object IBuildManager.CreateInstanceFromVirtualPath(string virtualPath, Type requiredBaseType) {\r
26             return BuildManager.CreateInstanceFromVirtualPath(virtualPath, requiredBaseType);\r
27         }\r
28 \r
29         ICollection IBuildManager.GetReferencedAssemblies() {\r
30             return BuildManager.GetReferencedAssemblies();\r
31         }\r
32 \r
33         // ASP.NET 4 methods\r
34         Stream IBuildManager.ReadCachedFile(string fileName) {\r
35             return (_readCachedFileDelegate != null) ? _readCachedFileDelegate(fileName) : null;\r
36         }\r
37 \r
38         Stream IBuildManager.CreateCachedFile(string fileName) {\r
39             return (_createCachedFileDelegate != null) ? _createCachedFileDelegate(fileName) : null;\r
40         }\r
41         #endregion\r
42     }\r
43 }\r