Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

33 lines
919 B
C#

// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Linq;
namespace System.Web.WebPages.Test
{
public class HashVirtualPathFactory : IVirtualPathFactory
{
private IDictionary<string, object> _pages;
public HashVirtualPathFactory(params WebPageExecutingBase[] pages)
{
_pages = pages.ToDictionary(p => p.VirtualPath, p => (object)p, StringComparer.OrdinalIgnoreCase);
}
public bool Exists(string virtualPath)
{
return _pages.ContainsKey(virtualPath);
}
public object CreateInstance(string virtualPath)
{
object value;
if (_pages.TryGetValue(virtualPath, out value))
{
return value;
}
return null;
}
}
}