using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace ElectronNET.API { /// /// Electron's process object is extended from the Node.js process object. It adds the /// events, properties, and methods. /// public sealed class Process { internal Process() { } internal static Process Instance { get { if (_process == null) { lock (_syncRoot) { if (_process == null) { _process = new Process(); } } } return _process; } } private static Process _process; private static readonly object _syncRoot = new(); /// /// The process.execPath property returns the absolute pathname of the executable that /// started the Node.js process. Symbolic links, if any, are resolved. /// public Task ExecPathAsync { get { return BridgeConnector.GetValueOverSocketAsync( "process-execPath", "process-execPath-Completed"); } } /// /// The process.argv property returns an array containing the command-line arguments passed /// when the Node.js process was launched. The first element will be process.execPath. See /// process.argv0 if access to the original value of argv[0] is needed. The second element /// will be the path to the JavaScript file being executed. The remaining elements will be /// any additional command-line arguments /// public Task ArgvAsync { get { return BridgeConnector.GetArrayOverSocketAsync( "process-argv", "process-argv-Completed"); } } /// /// The process.execPath property returns the absolute pathname of the executable that /// started the Node.js process. Symbolic links, if any, are resolved. /// public Task TypeAsync { get { return BridgeConnector.GetValueOverSocketAsync( "process-type", "process-type-Completed"); } } /// /// /// public Task VersionsAsync { get { return BridgeConnector.GetValueOverSocketAsync( "process-versions", "process-versions-Completed"); } } /// /// /// public Task DefaultAppAsync { get { return BridgeConnector.GetValueOverSocketAsync( "process-defaultApp", "process-defaultApp-Completed"); } } /// /// /// public Task IsMainFrameAsync { get { return BridgeConnector.GetValueOverSocketAsync( "process-isMainFrame", "process-isMainFrame-Completed"); } } /// /// /// public Task ResourcesPathAsync { get { return BridgeConnector.GetValueOverSocketAsync( "process-resourcesPath", "process-resourcesPath-Completed"); } } /// /// /// public Task UpTimeAsync { get { return BridgeConnector.GetValueOverSocketAsync( "process-uptime", "process-uptime-Completed"); } } /// /// /// public Task PidAsync { get { return BridgeConnector.GetValueOverSocketAsync( "process-pid", "process-pid-Completed"); } } /// /// /// public Task ArchAsync { get { return BridgeConnector.GetValueOverSocketAsync( "process-arch", "process-arch-Completed"); } } /// /// /// public Task PlatformAsync { get { return BridgeConnector.GetValueOverSocketAsync( "process-platform", "process-platform-Completed"); } } } }