Class PInvokeService
Represents a service for invoking platform (P/Invoke) methods with optional dependency injection support. This service implements the IPInvokeService interface, providing methods for platform invocation. This service inherits from DependencySingleton<PInvokeService>, which supports both dependency injection (DI) and non-DI scenarios
Inherited Members
Namespace: Coree.NETWindows.Services.PInvoke
Assembly: Coree.NETWindows.dll
Syntax
public class PInvokeService : DependencySingleton<PInvokeService>, IPInvokeService, IDependencySingleton
Constructors
| Edit this page View SourcePInvokeService(ILogger<PInvokeService>, IConfiguration)
Initializes a new instance of the PInvokeService class with the specified logger and configuration.
Declaration
public PInvokeService(ILogger<PInvokeService> logger, IConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
ILogger<PInvokeService> | logger | The logger instance for logging messages. |
IConfiguration | configuration | The configuration instance for accessing application settings. |
Methods
| Edit this page View SourceAllocConsole()
Allocates a new console window synchronously.
Declaration
public static void AllocConsole()
DisableCloseButton()
Synchronously disables the close button of the console window. This method internally calls the asynchronous version DisableCloseButtonAsync(CancellationToken) and waits for its completion.
Declaration
public void DisableCloseButton()
DisableCloseButtonAsync(CancellationToken)
Asynchronously disables the close button of the console window in a thread-safe manner. Utilizes Run(Action) to execute the operation potentially on a background thread.
Declaration
public Task DisableCloseButtonAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | A cancellation token that can be used to cancel the operation. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous operation. |
DisableQuickEditMode()
Disables the quick edit mode of the console.
Declaration
public void DisableQuickEditMode()
DisableQuickEditModeAsync(CancellationToken)
Disables the quick edit mode of the console.
Declaration
public Task DisableQuickEditModeAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation. |
FreeConsole()
Releases the current console window associated with the calling process synchronously.
Declaration
public void FreeConsole()
FreeConsoleAsync(CancellationToken)
Asynchronously releases the current console window associated with the calling process.
Declaration
public Task FreeConsoleAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation. |
SetConsoleColor(ConsoleColors, ConsoleColors)
Declaration
public static void SetConsoleColor(ConsoleManagement.ConsoleColors foregroundColor, ConsoleManagement.ConsoleColors backgroundColor)
Parameters
Type | Name | Description |
---|---|---|
ConsoleManagement.ConsoleColors | foregroundColor | |
ConsoleManagement.ConsoleColors | backgroundColor |
SetConsoleColors(Color, Color, Color, Color)
Declaration
public static void SetConsoleColors(Color screenTextColor, Color screenBackgroundColor, Color popupTextColor, Color popupBackgroundColor)
Parameters
Type | Name | Description |
---|---|---|
Color | screenTextColor | |
Color | screenBackgroundColor | |
Color | popupTextColor | |
Color | popupBackgroundColor |
SetConsoleFont(short, string)
Sets the font of the console window synchronously.
Declaration
public void SetConsoleFont(short fontSize = 14, string fontName = "Lucida Console")
Parameters
Type | Name | Description |
---|---|---|
short | fontSize | The size of the font to set (default is 14). |
string | fontName | The name of the font to set (default is "Lucida Console"). |
SetConsoleFontAsync(short, string, CancellationToken)
Sets the font of the console window asynchronously.
Declaration
public Task SetConsoleFontAsync(short fontSize = 14, string fontName = "Lucida Console", CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
short | fontSize | The size of the font to set (default is 14). |
string | fontName | The name of the font to set (default is "Lucida Console"). |
CancellationToken | cancellationToken | The cancellation token to cancel the operation (default is None). |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation. |
SetConsoleTitle(string)
Sets the title of the console window.
Declaration
public void SetConsoleTitle(string consoleTitle)
Parameters
Type | Name | Description |
---|---|---|
string | consoleTitle | The new title for the console window. |
SetConsoleTitleAsync(string, CancellationToken)
Sets the title of the console window.
Declaration
public Task SetConsoleTitleAsync(string consoleTitle, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | consoleTitle | The new title for the console window. |
CancellationToken | cancellationToken | The cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation. |