summaryrefslogtreecommitdiff
path: root/src/bindings/mono/eina_mono/eina_environment.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/mono/eina_mono/eina_environment.cs')
-rw-r--r--src/bindings/mono/eina_mono/eina_environment.cs53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/bindings/mono/eina_mono/eina_environment.cs b/src/bindings/mono/eina_mono/eina_environment.cs
new file mode 100644
index 0000000..7cef31c
--- /dev/null
+++ b/src/bindings/mono/eina_mono/eina_environment.cs
@@ -0,0 +1,53 @@
1using System;
2using System.Runtime.InteropServices;
3
4namespace Eina
5{
6
7/// <summary>
8/// Class to deal with native Environment variables.
9///
10/// <para>To be used in place of <see cref="System.Environment" /> methods when
11/// accessing the native environment directly.</para>
12/// <para>Since EFL 1.24.</para>
13/// </summary>
14internal static class Environment
15{
16 /// <summary>
17 /// Returns the value of the environment variable named <c>name</c>.
18 ///
19 /// <para>Since EFL 1.24</para>
20 /// </summary>
21 /// <param name="name">The name of the variable to be retrieved</param>
22 /// <returns>The value of the variable. <c>null</c> if not set.</returns>
23 public static string GetEnv(string name)
24 {
25 return Eina.NativeCustomExportFunctions.efl_mono_native_getenv(name);
26 }
27
28 /// <summary>
29 /// Sets a native environment variable.
30 ///
31 /// <para>Since EFL 1.24</para>
32 /// </summary>
33 /// <param name="name">The name of the variable</param>
34 /// <param name="value">The value to be set.</param>
35 /// <param name="overwrite"><c>true</c> if an existing variable must be overwritten.</param>
36 public static void SetEnv(string name, string value, bool overwrite=true)
37 {
38 Eina.Error error = Eina.NativeCustomExportFunctions.efl_mono_native_setenv(name, value, overwrite ? 1 : 0);
39 Eina.Error.Raise(error);
40 }
41}
42
43internal static partial class NativeCustomExportFunctions
44{
45 [DllImport(efl.Libs.CustomExports, CharSet=CharSet.Ansi)]
46 [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.StringKeepOwnershipMarshaler))]
47 public static extern string efl_mono_native_getenv(string name);
48
49 [DllImport(efl.Libs.CustomExports, CharSet=CharSet.Ansi)]
50 public static extern Eina.Error efl_mono_native_setenv(string name, string value, int overwrite);
51}
52
53} \ No newline at end of file