Coree.NETWindows
  • API
Show / Hide Table of Contents
  • Coree.NETWindows
    • KeyModifier
    • Keys
  • Coree.NETWindows.Classes
    • GlobalHotkey
  • Coree.NETWindows.NativeMethods
    • ConsoleManagement
    • ConsoleManagement.ConsoleColors
  • Coree.NETWindows.Services.PInvoke
    • IPInvokeService
    • PInvokeService
  • Coree.NETWindows.Utilities
    • MainContext

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

Inheritance
object
DependencySingleton<PInvokeService>
PInvokeService
Implements
IPInvokeService
IDependencySingleton
Inherited Members
DependencySingleton<PInvokeService>.logger
DependencySingleton<PInvokeService>.configuration
DependencySingleton<PInvokeService>.SetLogLevelFilter(LogLevel)
DependencySingleton<PInvokeService>.Instance
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Coree.NETWindows.Services.PInvoke
Assembly: Coree.NETWindows.dll
Syntax
public class PInvokeService : DependencySingleton<PInvokeService>, IPInvokeService, IDependencySingleton

Constructors

| Edit this page View Source

PInvokeService(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 Source

AllocConsole()

Allocates a new console window synchronously.

Declaration
public static void AllocConsole()
| Edit this page View Source

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()
| Edit this page View Source

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.

| Edit this page View Source

DisableQuickEditMode()

Disables the quick edit mode of the console.

Declaration
public void DisableQuickEditMode()
| Edit this page View Source

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.

| Edit this page View Source

FreeConsole()

Releases the current console window associated with the calling process synchronously.

Declaration
public void FreeConsole()
| Edit this page View Source

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.

| Edit this page View Source

SetConsoleColor(ConsoleColors, ConsoleColors)

Declaration
public static void SetConsoleColor(ConsoleManagement.ConsoleColors foregroundColor, ConsoleManagement.ConsoleColors backgroundColor)
Parameters
Type Name Description
ConsoleManagement.ConsoleColors foregroundColor
ConsoleManagement.ConsoleColors backgroundColor
| Edit this page View Source

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
| Edit this page View Source

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").

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

Implements

IPInvokeService
Coree.NETStandard.Abstractions.DependencySingleton.IDependencySingleton
  • Edit this page
  • View Source
In this article
Back to top