Exemplo n.º 1
0
        private static void EndWriteReport(IAsyncResult ar)
        {
            HidAsyncState       hidAsyncState       = (HidAsyncState)ar.AsyncState;
            WriteReportDelegate writeReportDelegate = (WriteReportDelegate)hidAsyncState.CallerDelegate;
            WriteCallback       writeCallback       = (WriteCallback)hidAsyncState.CallbackDelegate;
            bool success = writeReportDelegate.EndInvoke(ar);

            writeCallback?.Invoke(success);
        }
Exemplo n.º 2
0
        private void WriteToLog
        (
            PSOutputStream level,
            ConsoleColor?foregroundColor,
            ConsoleColor?backgroundColor,
            string message
        )
        {
            Debug.WriteLine($"[{level}] {message?.TrimEnd()}");

            // Looks like the default Write-Host requests just come in as black on black -- seems
            // kind of a bad design, but whatever...
            if (foregroundColor.HasValue && backgroundColor.HasValue &&
                foregroundColor.Value == backgroundColor.Value &&
                foregroundColor.Value == ConsoleColor.Black)
            {
                foregroundColor = backgroundColor = null;
            }

            WriteCallback?.Invoke(level, foregroundColor, backgroundColor, message);
        }