BadScript 2
Loading...
Searching...
No Matches
BadEnvironmentApi.cs
Go to the documentation of this file.
1using System.Collections;
2
5
7
8[BadInteropApi("Environment")]
9internal partial class BadEnvironmentApi
10{
11 protected override void AdditionalData(BadTable target)
12 {
13 target.SetProperty("CommandLine", Environment.CommandLine);
14 target.SetProperty("CurrentDirectory", Environment.CurrentDirectory);
15 target.SetProperty("ExitCode", Environment.ExitCode);
16 target.SetProperty("HasShutdownStarted", Environment.HasShutdownStarted);
17 target.SetProperty("Is64BitOperatingSystem", Environment.Is64BitOperatingSystem);
18 target.SetProperty("Is64BitProcess", Environment.Is64BitProcess);
19 target.SetProperty("MachineName", Environment.MachineName);
20 target.SetProperty("NewLine", Environment.NewLine);
21 target.SetProperty("OSVersion", Environment.OSVersion.ToString());
22 target.SetProperty("ProcessorCount", Environment.ProcessorCount);
23 target.SetProperty("StackTrace", Environment.StackTrace);
24 target.SetProperty("SystemDirectory", Environment.SystemDirectory);
25 target.SetProperty("SystemPageSize", Environment.SystemPageSize);
26 target.SetProperty("TickCount", Environment.TickCount);
27 target.SetProperty("UserDomainName", Environment.UserDomainName);
28 target.SetProperty("UserInteractive", Environment.UserInteractive);
29 target.SetProperty("UserName", Environment.UserName);
30 target.SetProperty("WorkingSet", Environment.WorkingSet);
31 target.SetProperty("CurrentManagedThreadId", Environment.CurrentManagedThreadId);
32 }
33
34 [BadMethod(description: "Expands Environment Variables in a string")]
35 [return: BadReturn("String with all Environment Variables Expanded")]
37 [BadParameter(
38 description: "A string containing the names of zero or more environment variables. Each environment variable is quoted with the percent sign character (%)."
39 )]
40 string s)
41 {
42 return Environment.ExpandEnvironmentVariables(s);
43 }
44
45 [BadMethod(description: "Gets the value of an Environment Variable")]
46 [return: BadReturn("The value of the Environment Variable")]
47 private string? GetEnvironmentVariable([BadParameter(description: "The name of the environment variable")] string s)
48 {
49 return Environment.GetEnvironmentVariable(s);
50 }
51
52 [BadMethod(description: "Sets the value of an Environment Variable")]
54 [BadParameter(description: "The name of an environment variable")]
55 string n,
56 [BadParameter(description: "A value to assign to variable")]
57 string v)
58 {
59 Environment.SetEnvironmentVariable(n, v);
60 }
61
62 [BadMethod(description: "Gets all Environment Variables")]
63 [return: BadReturn("A Table containing all Environment Variables")]
65 {
66 IDictionary d = Environment.GetEnvironmentVariables();
67 BadTable t = new BadTable();
68
69 foreach (DictionaryEntry de in d)
70 {
71 t.SetProperty(de.Key.ToString(), de.Value.ToString());
72 }
73
74 return t;
75 }
76
77 [BadMethod(description: "Gets the Commandline Arguments")]
78 [return: BadReturn("An Array containing all Commandline Arguments")]
80 {
81 return new BadArray(Environment.GetCommandLineArgs().Select(x => (BadObject)x).ToList());
82 }
83
84 [BadMethod(description: "Gets the Logical Drives")]
85 [return: BadReturn("An Array containing all Logical Drives")]
87 {
88 return new BadArray(Environment.GetLogicalDrives().Select(x => (BadObject)x).ToList());
89 }
90
91 [BadMethod(description: "Exits the Application")]
92 private void Exit([BadParameter(description: "The exit code to return to the operating system. Use 0 (zero) to indicate that the process completed successfully.")] decimal e)
93 {
94 Environment.Exit((int)e);
95 }
96
97 [BadMethod(description: "Terminates the process")]
98 private void FailFast([BadParameter(description: "A message that explains why the process was terminated, or null if no explanation is provided.")] string m)
99 {
100 Environment.FailFast(m);
101 }
102}
string? GetEnvironmentVariable([BadParameter(description:"The name of the environment variable")] string s)
void SetEnvironmentVariable([BadParameter(description:"The name of an environment variable")] string n, [BadParameter(description:"A value to assign to variable")] string v)
void FailFast([BadParameter(description:"A message that explains why the process was terminated, or null if no explanation is provided.")] string m)
string ExpandEnvironmentVariables([BadParameter(description:"A string containing the names of zero or more environment variables. Each environment variable is quoted with the percent sign character (%).")] string s)
void Exit([BadParameter(description:"The exit code to return to the operating system. Use 0 (zero) to indicate that the process completed successfully.")] decimal e)
Implements an Interop API for the BS2 Language.
Implements a Dynamic List/Array for the BadScript Language.
Definition BadArray.cs:17
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
Implements a Table Structure for the BadScript Language.
Definition BadTable.cs:14
Contains Common Interop APIs for the BadScript2 Runtime.
Contains the Interop Abstractions and Implementations for the BadScript2 Language.
Contains the Runtime Objects.
Definition BadArray.cs:10