CachedVaryBy varyby;
int status_code;
string status_desc;
- int content_length;
NameValueCollection headers;
List <DataItem> data;
{
public sealed class OutputCacheProviderCollection : ProviderCollection
{
- public OutputCacheProvider this [string name] {
+ public new OutputCacheProvider this [string name] {
get { return base [name] as OutputCacheProvider; }
}
using System.Threading;
using System.Web;
using System.Web.Configuration;
+using System.Web.Util;
namespace System.Web.Compilation
{
string SetAlPath (ProcessStartInfo info)
{
- if (HttpRuntime.RunningOnWindows) {
+ if (RuntimeHelpers.RunningOnWindows) {
string alPath;
string monoPath;
PropertyInfo gac = typeof (Environment).GetProperty ("GacPath", BindingFlags.Static|BindingFlags.NonPublic);
throw new FileNotFoundException ("Windows mono path not found: " + monoPath);
}
}
-
+
+#if NET_4_0
+ alPath = Path.Combine (p, "4.0\\al.exe");
+#else
alPath = Path.Combine (p, "2.0\\al.exe");
+#endif
if (!File.Exists (alPath)) {
+#if NET_4_0
+ alPath = Path.Combine(Path.GetDirectoryName (p), "lib\\net_4_0\\al.exe");
+#else
alPath = Path.Combine(Path.GetDirectoryName (p), "lib\\net_2_0\\al.exe");
+#endif
if (!File.Exists (alPath))
throw new FileNotFoundException ("Windows al path not found: " + alPath);
}
info.FileName = monoPath;
return alPath;
} else {
+#if NET_4_0
+ info.FileName = "al";
+#else
info.FileName = "al2";
+#endif
return String.Empty;
}
}
static int BUILD_MANAGER_VIRTUAL_PATH_CACHE_PREFIX_LENGTH = BUILD_MANAGER_VIRTUAL_PATH_CACHE_PREFIX.Length;
static readonly object bigCompilationLock = new object ();
+ static readonly object virtualPathsToIgnoreLock = new object ();
static readonly char[] virtualPathsToIgnoreSplitChars = {','};
static EventHandlerList events = new EventHandlerList ();
static object buildManagerRemoveEntryEvent = new object ();
static bool hosted;
- static IEqualityComparer <string> comparer;
- static StringComparison stringComparer;
static Dictionary <string, bool> virtualPathsToIgnore;
+ static bool virtualPathsToIgnoreChecked;
static bool haveVirtualPathsToIgnore;
static List <Assembly> AppCode_Assemblies = new List<Assembly>();
static List <Assembly> TopLevel_Assemblies = new List<Assembly>();
static BuildManager ()
{
- if (HttpRuntime.CaseInsensitive) {
- comparer = StringComparer.CurrentCultureIgnoreCase;
- stringComparer = StringComparison.CurrentCultureIgnoreCase;
- } else {
- comparer = StringComparer.CurrentCulture;
- stringComparer = StringComparison.CurrentCulture;
- }
-
hosted = (AppDomain.CurrentDomain.GetData (ApplicationHost.MonoHostedDataKey) as string) == "yes";
- buildCache = new Dictionary <string, BuildManagerCacheItem> (comparer);
+ buildCache = new Dictionary <string, BuildManagerCacheItem> (RuntimeHelpers.StringEqualityComparerCulture);
#if SYSTEMCORE_DEP
buildCacheLock = new ReaderWriterLockSlim ();
#else
is_precompiled = String.IsNullOrEmpty (appPath) ? false : File.Exists ((precomp_name = Path.Combine (appPath, "PrecompiledApp.config")));
if (is_precompiled)
is_precompiled = LoadPrecompilationInfo (precomp_name);
- LoadVirtualPathsToIgnore ();
}
// Deal with precompiled sites deployed in a different virtual path
}
if (store) {
if (precompiled == null)
- precompiled = new Dictionary<string, PreCompilationData> (comparer);
+ precompiled = new Dictionary<string, PreCompilationData> (RuntimeHelpers.StringEqualityComparerCulture);
precompiled.Add (pc_data.VirtualPath, pc_data);
}
return pc_data;
static void AddPathToIgnore (string vp)
{
if (virtualPathsToIgnore == null)
- virtualPathsToIgnore = new Dictionary <string, bool> (comparer);
+ virtualPathsToIgnore = new Dictionary <string, bool> (RuntimeHelpers.StringEqualityComparerCulture);
VirtualPath path = GetAbsoluteVirtualPath (vp);
string vpAbsolute = path.Absolute;
return null;
foreach (BuildProvider bp in group) {
- if (String.Compare (path, req.MapPath (bp.VirtualPath), stringComparer) == 0)
+ if (String.Compare (path, req.MapPath (bp.VirtualPath), RuntimeHelpers.StringComparison) == 0)
return bp;
}
}
List <BuildProvider> failedBuildProviders = null;
+ StringComparison stringComparison = RuntimeHelpers.StringComparison;
foreach (BuildProvider bp in group) {
bvp = bp.VirtualPath;
if (HasCachedItemNoLock (bvp))
try {
bp.GenerateCode (abuilder);
} catch (Exception ex) {
- if (String.Compare (bvp, vpabsolute, stringComparer) == 0) {
+ if (String.Compare (bvp, vpabsolute, stringComparison) == 0) {
if (ex is CompilationException || ex is ParseException)
throw;
internal static bool IgnoreVirtualPath (string virtualPath)
{
+ if (!virtualPathsToIgnoreChecked) {
+ lock (virtualPathsToIgnoreLock) {
+ if (!virtualPathsToIgnoreChecked)
+ LoadVirtualPathsToIgnore ();
+ virtualPathsToIgnoreChecked = true;
+ }
+ }
+
if (!haveVirtualPathsToIgnore)
return false;
readonly string virtualPathDirectory;
CompilationSection compilationSection;
Dictionary <string, BuildProvider> buildProviders;
- IEqualityComparer <string> dictionaryComparer;
- StringComparison stringComparer;
VirtualPathProvider vpp;
CompilationSection CompilationSection {
this.vpp = HostingEnvironment.VirtualPathProvider;
this.virtualPath = virtualPath;
this.virtualPathDirectory = VirtualPathUtility.GetDirectory (virtualPath.Absolute);
- if (HttpRuntime.CaseInsensitive) {
- this.stringComparer = StringComparison.OrdinalIgnoreCase;
- this.dictionaryComparer = StringComparer.OrdinalIgnoreCase;
- } else {
- this.stringComparer = StringComparison.Ordinal;
- this.dictionaryComparer = StringComparer.Ordinal;
- }
}
public List <BuildProviderGroup> Build (bool single)
if (single) {
AddVirtualFile (GetVirtualFile (virtualPath.Absolute), bpcoll);
} else {
- var cache = new Dictionary <string, bool> (dictionaryComparer);
+ var cache = new Dictionary <string, bool> (RuntimeHelpers.StringEqualityComparer);
AddVirtualDir (GetVirtualDirectory (virtualPath.Absolute), bpcoll, cache);
cache = null;
if (buildProviders == null || buildProviders.Count == 0)
bool AddBuildProvider (BuildProvider buildProvider)
{
if (buildProviders == null)
- buildProviders = new Dictionary <string, BuildProvider> (dictionaryComparer);
+ buildProviders = new Dictionary <string, BuildProvider> (RuntimeHelpers.StringEqualityComparer);
string bpPath = buildProvider.VirtualPath;
if (buildProviders.ContainsKey (bpPath))
if (BuildManager.HasCachedItemNoLock (buildProvider.VirtualPath))
return;
+ StringComparison stringComparison = RuntimeHelpers.StringComparison;
if (buildProvider is ApplicationFileBuildProvider || buildProvider is ThemeDirectoryBuildProvider) {
// global.asax and theme directory go into their own assemblies
myGroup = new BuildProviderGroup ();
}
// There should be one assembly per virtual dir
- if (String.Compare (bpPath, VirtualPathUtility.GetDirectory (bp.VirtualPath), stringComparer) != 0) {
+ if (String.Compare (bpPath, VirtualPathUtility.GetDirectory (bp.VirtualPath), stringComparison) != 0) {
canAdd = false;
break;
}
}
myGroup.AddProvider (buildProvider);
- if (String.Compare (bpPath, virtualPathDirectory, stringComparer) == 0)
+ if (String.Compare (bpPath, virtualPathDirectory, stringComparison) == 0)
myGroup.Master = true;
}
+2010-03-04 Marek Habersack <mhabersack@novell.com>
+
+ * BuildManager.cs: do less work in the static constructor
+
2010-02-27 Marek Habersack <mhabersack@novell.com>
* BuildManager.cs: count only builds of updated files before
} else
relPath = path;
- _Configuration cnew;
-
HttpRequest req = context != null ? context.Request : null;
if (req != null) {
string vdir = VirtualPathUtility.GetDirectory (req.Path);
loginPath = context.Request.MapPath (loginPage);
} catch {} // ignore
- context.SkipAuthorization = String.Compare (reqPath, loginPath, HttpRuntime.CaseInsensitive, Helpers.InvariantCulture) == 0;
+ context.SkipAuthorization = String.Compare (reqPath, loginPath, RuntimeHelpers.CaseInsensitive, Helpers.InvariantCulture) == 0;
#if NET_2_0
//TODO: need to check that the handler is System.Web.Handlers.AssemblyResourceLoader type
{
DbCommand cmd;
DbCommand deleteCmd = null;
- DbParameter param;
-
string sessItems = Serialize((SessionStateItemCollection)item.Items);
DbProviderFactory factory = ProviderFactory;
string appName = ApplicationName;
string appName = ApplicationName;
DbCommand cmd = null;
DbDataReader reader = null;
- DbParameter param;
DbParameterCollection parameters;
DateTime expires;
string serializedItems = String.Empty;
bool nodeIsSelected = node == SelectedNode && selectedNodeStyle != null;
if (!nodeIsSelected && selectedNodeStyle != null) {
if (!String.IsNullOrEmpty (activeSiteMapPath))
- nodeIsSelected = String.Compare (activeSiteMapPath,
- node.NavigateUrl,
- HttpRuntime.CaseInsensitive ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) == 0;
+ nodeIsSelected = String.Compare (activeSiteMapPath, node.NavigateUrl, RuntimeHelpers.StringComparison) == 0;
}
AddNodeStyle (writer, node, level, nodeIsSelected);
try {
target.RaiseCallbackEvent (callbackArgument);
} catch (Exception ex) {
- callbackEventError = String.Concat ("e", HttpRuntime.IsDebuggingEnabled ? ex.ToString () : ex.Message);
+ callbackEventError = String.Concat ("e", RuntimeHelpers.DebuggingEnabled ? ex.ToString () : ex.Message);
}
}
try {
callBackResult = target.GetCallbackResult ();
} catch (Exception ex) {
- return String.Concat ("e", HttpRuntime.IsDebuggingEnabled ? ex.ToString () : ex.Message);
+ return String.Concat ("e", RuntimeHelpers.DebuggingEnabled ? ex.ToString () : ex.Message);
}
string eventValidation = ClientScript.GetEventValidationStateFormatted ();
throw new Exception ("Error while loading " + s, e);
}
- if (ex != null && HttpRuntime.IsDebuggingEnabled) {
+ if (ex != null && RuntimeHelpers.DebuggingEnabled) {
Console.WriteLine ("**** DEBUG MODE *****");
Console.WriteLine ("Bad assembly found in bin/. Exception (ignored):");
Console.WriteLine (ex);
+2010-03-04 Marek Habersack <mhabersack@novell.com>
+
+ * RuntimeHelpers.cs: added. Contains methods moved here from
+ HttpRuntime, so that initialization sequence of various objects is
+ independent of HttpRuntime.
+
2009-03-01 Gonzalo Paniagua Javier <gonzalo@novell.com>
* WebEncoding.cs: another GetWebApplication here.
--- /dev/null
+//
+// System.Web.Util.RuntimeHelpers
+//
+// Authors:
+// Marek Habersack (mhabersack@novell.com)
+//
+// (C) 2006-2010 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Reflection;
+using System.Web.Configuration;
+
+namespace System.Web.Util
+{
+ static class RuntimeHelpers
+ {
+ public static bool CaseInsensitive {
+ get; private set;
+ }
+
+ public static bool DebuggingEnabled {
+ get {
+ CompilationSection cs = WebConfigurationManager.GetSection ("system.web/compilation") as CompilationSection;
+ if (cs != null)
+ return cs.Debug;
+
+ return false;
+ }
+ }
+
+ public static IEqualityComparer <string> StringEqualityComparer {
+ get; private set;
+ }
+
+ public static IEqualityComparer <string> StringEqualityComparerCulture {
+ get; private set;
+ }
+
+ public static bool IsUncShare {
+ get; private set;
+ }
+
+ public static string MonoVersion {
+ get; private set;
+ }
+
+ public static bool RunningOnWindows {
+ get; private set;
+ }
+
+ public static StringComparison StringComparison {
+ get; private set;
+ }
+
+ public static StringComparison StringComparisonCulture {
+ get; private set;
+ }
+
+ static RuntimeHelpers ()
+ {
+ PlatformID pid = Environment.OSVersion.Platform;
+ RunningOnWindows = ((int) pid != 128 && pid != PlatformID.Unix && pid != PlatformID.MacOSX);
+
+ if (RunningOnWindows) {
+ CaseInsensitive = true;
+ string appDomainAppPath = AppDomain.CurrentDomain.GetData (".appPath") as string;
+ if (!String.IsNullOrEmpty (appDomainAppPath)) {
+ try {
+ IsUncShare = new Uri (appDomainAppPath).IsUnc;
+ } catch {
+ // ignore
+ }
+ }
+ } else {
+ string mono_iomap = Environment.GetEnvironmentVariable ("MONO_IOMAP");
+ if (!String.IsNullOrEmpty (mono_iomap)) {
+ if (mono_iomap == "all")
+ CaseInsensitive = true;
+ else {
+ string[] parts = mono_iomap.Split (':');
+ foreach (string p in parts) {
+ if (p == "all" || p == "case") {
+ CaseInsensitive = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (CaseInsensitive) {
+ StringEqualityComparer = StringComparer.OrdinalIgnoreCase;
+ StringEqualityComparerCulture = StringComparer.CurrentCultureIgnoreCase;
+ StringComparison = StringComparison.OrdinalIgnoreCase;
+ StringComparisonCulture = StringComparison.CurrentCultureIgnoreCase;
+ } else {
+ StringEqualityComparer = StringComparer.Ordinal;
+ StringEqualityComparerCulture = StringComparer.CurrentCulture;
+ StringComparison = StringComparison.Ordinal;
+ StringComparisonCulture = StringComparison.CurrentCulture;
+ }
+
+ string monoVersion = null;
+ try {
+ Type monoRuntime = Type.GetType ("Mono.Runtime", false);
+ if (monoRuntime != null) {
+ MethodInfo mi = monoRuntime.GetMethod ("GetDisplayName", BindingFlags.Static | BindingFlags.NonPublic);
+ if (mi != null)
+ monoVersion = mi.Invoke (null, new object [0]) as string;
+ }
+ } catch {
+ // ignore
+ }
+
+ if (monoVersion == null)
+ monoVersion = Environment.Version.ToString ();
+
+ MonoVersion = monoVersion;
+ }
+ }
+}
System.Web.Util/ICalls.cs
System.Web.Util/IWebObjectFactory.cs
System.Web.Util/IWebPropertyAccessor.cs
+System.Web.Util/RuntimeHelpers.cs
System.Web.Util/SearchPattern.cs
System.Web.Util/SerializationHelper.cs
System.Web.Util/StrUtils.cs
+2010-03-04 Marek Habersack <mhabersack@novell.com>
+
+ * HttpRuntime.cs: do less work in the static constructor. Most of
+ the code was moved to System.Web.Util.RuntimeHelpers. Properties
+ which have been moved: MonoVersion, RunningOnWindows,
+ CaseInsensitive, IsDebuggingEnabled
+
2010-02-27 Marek Habersack <mhabersack@novell.com>
* HttpRuntime.cs: added internal property DomainUnloading.
}
#if !TARGET_JVM
public bool IsDebuggingEnabled {
- get { return HttpRuntime.IsDebuggingEnabled; }
+ get { return RuntimeHelpers.DebuggingEnabled; }
}
#endif
public IDictionary Items {
// we should expire the entries (or just store them in InternalCache?)
IResourceProvider rp = null;
if (!resource_providers.TryGetValue (virtualPath, out rp)) {
- if (isLocal) {
- HttpContext ctx = HttpContext.Current;
- HttpRequest req = ctx != null ? ctx.Request : null;
+ if (isLocal)
rp = provider_factory.CreateLocalResourceProvider (virtualPath);
- } else
+ else
rp = provider_factory.CreateGlobalResourceProvider (virtualPath);
if (rp == null) {
- if (isLocal) {
- HttpContext ctx = HttpContext.Current;
- HttpRequest req = ctx != null ? ctx.Request : null;
+ if (isLocal)
rp = DefaultProviderFactory.CreateLocalResourceProvider (virtualPath);
- } else
+ else
rp = DefaultProviderFactory.CreateGlobalResourceProvider (virtualPath);
if (rp == null)
if (pathRelative || pathAbsolute) {
if (pathRelative)
filePath = VirtualPathUtility.ToAbsolute (filePath);
- else
- filePath = filePath;
} else
filePath = VirtualPathUtility.AppendTrailingSlash (req.BaseVirtualDir) + filePath;
if (showTrace) {
builder.Append ("<hr style=\"color: silver\"/>");
builder.AppendFormat ("<strong>Version information: </strong> Mono Runtime Version: <tt>{0}</tt>; ASP.NET Version: <tt>{1}</tt></body></html>\r\n",
- HttpRuntime.MonoVersion, Environment.Version);
+ RuntimeHelpers.MonoVersion, Environment.Version);
string trace, message;
bool haveTrace;
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class HttpRuntime
{
- static bool caseInsensitive;
- static bool runningOnWindows;
- static bool isunc;
- static string monoVersion;
static bool domainUnloading;
#if TARGET_J2EE
static HttpRuntime ()
{
- PlatformID pid = Environment.OSVersion.Platform;
- runningOnWindows = ((int) pid != 128 && pid != PlatformID.Unix && pid != PlatformID.MacOSX);
-
- if (runningOnWindows) {
- caseInsensitive = true;
- if (AppDomainAppPath != null)
- isunc = new Uri (AppDomainAppPath).IsUnc;
- } else {
- string mono_iomap = Environment.GetEnvironmentVariable ("MONO_IOMAP");
- if (mono_iomap != null) {
- if (mono_iomap == "all")
- caseInsensitive = true;
- else {
- string[] parts = mono_iomap.Split (':');
- foreach (string p in parts) {
- if (p == "all" || p == "case") {
- caseInsensitive = true;
- break;
- }
- }
- }
- }
- }
-
- Type monoRuntime = Type.GetType ("Mono.Runtime", false);
- monoVersion = null;
- if (monoRuntime != null) {
- MethodInfo mi = monoRuntime.GetMethod ("GetDisplayName", BindingFlags.Static | BindingFlags.NonPublic);
- if (mi != null)
- monoVersion = mi.Invoke (null, new object [0]) as string;
- }
-
- if (monoVersion == null)
- monoVersion = Environment.Version.ToString ();
-
#if !TARGET_J2EE
firstRun = true;
try {
public static bool IsOnUNCShare {
[AspNetHostingPermission (SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Low)]
get {
- return isunc;
+ return RuntimeHelpers.IsUncShare;
}
}
}
}
#endif // #if !TARGET_J2EE
-
- internal static string MonoVersion {
- get { return monoVersion; }
- }
-
- internal static bool RunningOnWindows {
- get { return runningOnWindows; }
- }
-
- internal static bool CaseInsensitive {
- get { return caseInsensitive; }
- }
-
- internal static bool IsDebuggingEnabled {
- get {
- CompilationSection cs = WebConfigurationManager.GetSection ("system.web/compilation") as CompilationSection;
- if (cs != null)
- return cs.Debug;
-
- return false;
- }
- }
internal static TraceManager TraceManager {
get {
{
static bool ValidFileName (string fileName)
{
- if (!HttpRuntime.RunningOnWindows)
+ if (!RuntimeHelpers.RunningOnWindows)
return true;
if (fileName == null || fileName.Length == 0)
{
public abstract class StaticSiteMapProvider : SiteMapProvider
{
- static readonly StringComparison stringComparison = HttpRuntime.CaseInsensitive ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
-
Dictionary<string, SiteMapNode> keyToNode;
Dictionary<SiteMapNode, SiteMapNode> nodeToParent;
Dictionary<SiteMapNode, SiteMapNodeCollection> nodeToChildren;
if (!String.IsNullOrEmpty (nodeUrl)) {
string url = MapUrl (nodeUrl);
SiteMapNode foundNode = FindSiteMapNode (url);
- if (foundNode != null && String.Compare (foundNode.Url, url, stringComparison) == 0)
+ if (foundNode != null && String.Compare (foundNode.Url, url, RuntimeHelpers.StringComparison) == 0)
throw new InvalidOperationException (String.Format (
"Multiple nodes with the same URL '{0}' were found. " +
"StaticSiteMapProvider requires that sitemap nodes have unique URLs.",
static VirtualPathUtility ()
{
try {
- runningOnWindows = HttpRuntime.RunningOnWindows;
+ runningOnWindows = RuntimeHelpers.RunningOnWindows;
var monoSettings = WebConfigurationManager.GetWebApplicationSection ("system.web/monoSettings") as MonoSettingsSection;
if (monoSettings != null)
monoSettingsVerifyCompatibility = monoSettings.VerificationCompatibility != 1;
public class XmlSiteMapProvider : StaticSiteMapProvider, IDisposable
{
static readonly char [] seperators = { ';', ',' };
- static readonly StringComparison stringComparison = HttpRuntime.RunningOnWindows ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
bool initialized;
string fileVirtualPath;
if (file == null)
throw new HttpException ("Virtual path '" + virtualPath + "' cannot be mapped to physical path.");
- if (String.Compare (Path.GetExtension (file), ".sitemap", stringComparison) != 0)
+ if (String.Compare (Path.GetExtension (file), ".sitemap", RuntimeHelpers.StringComparison) != 0)
throw new InvalidOperationException (String.Format ("The file {0} has an invalid extension, only .sitemap files are allowed in XmlSiteMapProvider.",
String.IsNullOrEmpty (virtualPath) ? Path.GetFileName (file) : virtualPath));