You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by di...@apache.org on 2010/05/07 23:09:18 UTC
svn commit: r942227 -
/lucene/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs
Author: digy
Date: Fri May 7 21:09:18 2010
New Revision: 942227
URL: http://svn.apache.org/viewvc?rev=942227&view=rev
Log:
LUCENENET-357 Lucene.Net in Medium Trust (Mostly won't work on shared hosts / Mosso cloud etc due to 'Trust' levels) (Constants.patch)
Modified:
lucene/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs
Modified: lucene/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs
URL: http://svn.apache.org/viewvc/lucene/lucene.net/trunk/C%23/src/Lucene.Net/Util/Constants.cs?rev=942227&r1=942226&r2=942227&view=diff
==============================================================================
--- lucene/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs (original)
+++ lucene/lucene.net/trunk/C#/src/Lucene.Net/Util/Constants.cs Fri May 7 21:09:18 2010
@@ -46,7 +46,7 @@ namespace Lucene.Net.Util
public static readonly bool JAVA_1_3 = JAVA_VERSION.StartsWith("1.3.");
/// <summary>The value of <tt>System.getProperty("os.name")</tt>. *</summary>
- public static readonly System.String OS_NAME = System.Environment.GetEnvironmentVariable("OS") ?? "Linux";
+ public static readonly System.String OS_NAME = GetEnvironmentVariable("OS","Windows_NT") ?? "Linux";
/// <summary>True iff running on Linux. </summary>
public static readonly bool LINUX = OS_NAME.StartsWith("Linux");
/// <summary>True iff running on Windows. </summary>
@@ -54,8 +54,8 @@ namespace Lucene.Net.Util
/// <summary>True iff running on SunOS. </summary>
public static readonly bool SUN_OS = OS_NAME.StartsWith("SunOS");
- public static readonly System.String OS_ARCH = System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
- public static readonly System.String OS_VERSION = System.Environment.OSVersion.ToString();
+ public static readonly System.String OS_ARCH = GetEnvironmentVariable("PROCESSOR_ARCHITECTURE","x86");
+ public static readonly System.String OS_VERSION = GetEnvironmentVariable("OS_VERSION", "?");
public static readonly System.String JAVA_VENDOR = SupportClass.AppSettings.Get("java.vendor", "");
// NOTE: this logic may not be correct; if you know of a
@@ -86,6 +86,23 @@ namespace Lucene.Net.Util
LUCENE_VERSION = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
- }
- }
+ }
+
+ #region MEDIUM-TRUST Support
+ static string GetEnvironmentVariable(string variable, string defaultValueOnSecurityException)
+ {
+ try
+ {
+ if (variable == "OS_VERSION") return System.Environment.OSVersion.ToString();
+
+ return System.Environment.GetEnvironmentVariable(variable);
+ }
+ catch (System.Security.SecurityException)
+ {
+ return defaultValueOnSecurityException;
+ }
+
+ }
+ #endregion
+ }
}
\ No newline at end of file