Class SystemProperties
Helper for environment variables. This class helps to convert the environment variables to int or bool data types and also silently handles read permission errors.
For instructions how to set environment variables for your OS, see https://www.schrodinger.com/kb/1842.
Note that if you want to load any of these settings for your application from a
configuration file, it is recommended your application load them at startup and
call Set
Set the environment variable lucene.ignoreSecurityExceptions
to false
to change the read behavior of these methods to throw the underlying exception
instead of returning the default value.
Inheritance
Namespace: Lucene.Net.Support
Assembly: Lucene.Net.dll
Syntax
public static class SystemProperties : object
Methods
| Improve this Doc View SourceGetProperty(String)
Retrieves the value of an environment variable from the current process.
Declaration
public static string GetProperty(string key)
Parameters
Type | Name | Description |
---|---|---|
System. |
key | The name of the environment variable. |
Returns
Type | Description |
---|---|
System. |
The environment variable value. |
GetProperty(String, String)
Retrieves the value of an environment variable from the current process, with a default value if it doens't exist or the caller doesn't have permission to read the value.
Declaration
public static string GetProperty(string key, string defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System. |
key | The name of the environment variable. |
System. |
defaultValue | The value to use if the environment variable does not exist or the caller doesn't have permission to read the value. |
Returns
Type | Description |
---|---|
System. |
The environment variable value. |
GetPropertyAsBoolean(String)
Retrieves the value of an environment variable from the current process
as false
.
Declaration
public static bool GetPropertyAsBoolean(string key)
Parameters
Type | Name | Description |
---|---|---|
System. |
key | The name of the environment variable. |
Returns
Type | Description |
---|---|
System. |
The environment variable value. |
GetPropertyAsBoolean(String, Boolean)
Retrieves the value of an environment variable from the current process as
Declaration
public static bool GetPropertyAsBoolean(string key, bool defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System. |
key | The name of the environment variable. |
System. |
defaultValue | The value to use if the environment variable does not exist,
the caller doesn't have permission to read the value, or the value cannot be cast to |
Returns
Type | Description |
---|---|
System. |
The environment variable value. |
GetPropertyAsInt32(String)
Retrieves the value of an environment variable from the current process
as 0
.
Declaration
public static int GetPropertyAsInt32(string key)
Parameters
Type | Name | Description |
---|---|---|
System. |
key | The name of the environment variable. |
Returns
Type | Description |
---|---|
System. |
The environment variable value. |
GetPropertyAsInt32(String, Int32)
Retrieves the value of an environment variable from the current process as
Declaration
public static int GetPropertyAsInt32(string key, int defaultValue)
Parameters
Type | Name | Description |
---|---|---|
System. |
key | The name of the environment variable. |
System. |
defaultValue | The value to use if the environment variable does not exist,
the caller doesn't have permission to read the value, or the value cannot be cast to |
Returns
Type | Description |
---|---|
System. |
The environment variable value. |
SetProperty(String, String)
Creates, modifies, or deletes an environment variable stored in the current process.
Declaration
public static void SetProperty(string key, string value)
Parameters
Type | Name | Description |
---|---|---|
System. |
key | The name of the environment variable. |
System. |
value | The new environment variable value. |