diff --git a/ElectronNET.API/Interfaces/IProcess.cs b/ElectronNET.API/Interfaces/IProcess.cs new file mode 100644 index 0000000..dc2c352 --- /dev/null +++ b/ElectronNET.API/Interfaces/IProcess.cs @@ -0,0 +1,76 @@ +using System.Threading.Tasks; + +namespace ElectronNET.API.Interfaces +{ + /// + /// Electron's process object is extended from the Node.js process object. It adds the + /// events, properties, and methods. + /// + public interface IProcess + { + /// + /// The process.execPath property returns the absolute pathname of the executable that + /// started the Node.js process. Symbolic links, if any, are resolved. + /// + Task ExecPathAsync { get; } + + /// + /// 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 + /// + Task ArgvAsync { get; } + + /// + /// The process.execPath property returns the absolute pathname of the executable that + /// started the Node.js process. Symbolic links, if any, are resolved. + /// + Task TypeAsync { get; } + + /// + /// The process.versions property returns an object listing the version strings of + /// chrome and electron. + /// + Task VersionsAsync { get; } + + /// + /// A Boolean. When app is started by being passed as parameter to the default app, this + /// property is true in the main process, otherwise it is false. + /// + Task DefaultAppAsync { get; } + + /// + /// A Boolean, true when the current renderer context is the "main" renderer frame. If you + /// want the ID of the current frame you should use webFrame.routingId + /// + Task IsMainFrameAsync { get; } + + /// + /// A String representing the path to the resources directory. + /// + Task ResourcesPathAsync { get; } + + /// + /// The number of seconds the current Node.js process has been running. The return value + /// includes fractions of a second. Use Math.floor() to get whole seconds. + /// + Task UpTimeAsync { get; } + + /// + /// The PID of the electron process + /// + Task PidAsync { get; } + + /// + /// The operating system CPU architecture for which the Node.js binary was compiled + /// + Task ArchAsync { get; } + + /// + /// A string identifying the operating system platform on which the Node.js process is running + /// + Task PlatformAsync { get; } + } +} \ No newline at end of file diff --git a/ElectronNET.API/Process.cs b/ElectronNET.API/Process.cs index 7620fa7..34cd72a 100644 --- a/ElectronNET.API/Process.cs +++ b/ElectronNET.API/Process.cs @@ -1,5 +1,6 @@ using System.Threading; using System.Threading.Tasks; +using ElectronNET.API.Interfaces; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -9,7 +10,7 @@ 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 + public sealed class Process : IProcess { internal Process() { } diff --git a/ElectronNET.API/ServiceCollectionExtensions.cs b/ElectronNET.API/ServiceCollectionExtensions.cs index 6ad963c..d9a5974 100755 --- a/ElectronNET.API/ServiceCollectionExtensions.cs +++ b/ElectronNET.API/ServiceCollectionExtensions.cs @@ -33,23 +33,23 @@ namespace ElectronNET.API .AddSingleton(provider => Dock.Instance) .AddSingleton(provider => new ApplicationSocket { Socket = BridgeConnector.Socket, }) // this set for proper dependency injection - .AddSingleton(provider => IpcMain.Instance) - .AddSingleton(provider => App.Instance) - .AddSingleton(provider => AutoUpdater.Instance) - .AddSingleton(provider => WindowManager.Instance) - .AddSingleton(provider => Menu.Instance) - .AddSingleton(provider => Dialog.Instance) - .AddSingleton(provider => Notification.Instance) - .AddSingleton(provider => Tray.Instance) - .AddSingleton(provider => GlobalShortcut.Instance) - .AddSingleton(provider => Shell.Instance) - .AddSingleton(provider => Screen.Instance) - .AddSingleton(provider => Clipboard.Instance) - .AddSingleton(provider => HostHook.Instance) - .AddSingleton(provider => PowerMonitor.Instance) - .AddSingleton(provider => NativeTheme.Instance) - .AddSingleton(provider => Dock.Instance) + .AddSingleton(_ => IpcMain.Instance) + .AddSingleton(_ => App.Instance) + .AddSingleton(_ => AutoUpdater.Instance) + .AddSingleton(_ => WindowManager.Instance) + .AddSingleton(_ => Menu.Instance) + .AddSingleton(_ => Dialog.Instance) + .AddSingleton(_ => Notification.Instance) + .AddSingleton(_ => Tray.Instance) + .AddSingleton(_ => GlobalShortcut.Instance) + .AddSingleton(_ => Shell.Instance) + .AddSingleton(_ => Screen.Instance) + .AddSingleton(_ => Clipboard.Instance) + .AddSingleton(_ => HostHook.Instance) + .AddSingleton(_ => PowerMonitor.Instance) + .AddSingleton(_ => NativeTheme.Instance) + .AddSingleton(_ => Dock.Instance) + .AddSingleton(_ => Process.Instance) .AddSingleton(provider => provider.GetService()); - .AddSingleton(provider => Process.Instance); } }