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(description:
38 "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")]
53 private void SetEnvironmentVariable([BadParameter(description: "The name of an environment variable")] string n,
54 [BadParameter(description: "A value to assign to variable")]
55 string v)
56 {
57 Environment.SetEnvironmentVariable(n, v);
58 }
59
60 [BadMethod(description: "Gets all Environment Variables")]
61 [return: BadReturn("A Table containing all Environment Variables")]
63 {
64 IDictionary d = Environment.GetEnvironmentVariables();
65 BadTable t = new BadTable();
66
67 foreach (DictionaryEntry de in d)
68 {
69 t.SetProperty(de.Key.ToString(), de.Value.ToString());
70 }
71
72 return t;
73 }
74
75 [BadMethod(description: "Gets the Commandline Arguments")]
76 [return: BadReturn("An Array containing all Commandline Arguments")]
78 {
79 return new BadArray(Environment.GetCommandLineArgs()
80 .Select(x => (BadObject)x)
81 .ToList()
82 );
83 }
84
85 [BadMethod(description: "Gets the Logical Drives")]
86 [return: BadReturn("An Array containing all Logical Drives")]
88 {
89 return new BadArray(Environment.GetLogicalDrives()
90 .Select(x => (BadObject)x)
91 .ToList()
92 );
93 }
94
95 [BadMethod(description: "Exits the Application")]
96 private void Exit(
97 [BadParameter(description:
98 "The exit code to return to the operating system. Use 0 (zero) to indicate that the process completed successfully."
99 )]
100 decimal e)
101 {
102 Environment.Exit((int)e);
103 }
104
105 [BadMethod(description: "Terminates the process")]
106 private void FailFast(
107 [BadParameter(description:
108 "A message that explains why the process was terminated, or null if no explanation is provided."
109 )]
110 string m)
111 {
112 Environment.FailFast(m);
113 }
114}
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