Replace Where-Object with .where Method (#2212)

* initialize Windev branch

* Formatting

* more Formatting

* fix applications

* init

* remove timer

* Compile Winutil

* revert winutil.ps1

* revert winutil.ps1

* update Get Winutilvariables to use .where method

---------

Co-authored-by: Marterich <Marterich@users.noreply.github.com>
This commit is contained in:
Martin Wiethan 2024-06-29 00:02:32 +02:00 committed by GitHub
parent 0c32d016b4
commit ab384029f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 9 deletions

View File

@ -11,9 +11,7 @@ function Get-WinUtilVariables {
[Parameter()]
[string[]]$Type
)
$keys = $sync.keys | Where-Object { $_ -like "WPF*" }
$keys = ($sync.keys).where{ $_ -like "WPF*" }
if ($Type) {
$output = $keys | ForEach-Object {
Try {

View File

@ -10,7 +10,7 @@ $InitialSessionState = [System.Management.Automation.Runspaces.InitialSessionSta
$InitialSessionState.Variables.Add($hashVars)
# Get every private function and add them to the session state
$functions = Get-ChildItem function:\ | Where-Object {$_.name -like "*winutil*" -or $_.name -like "*WPF*"}
$functions = (Get-ChildItem function:\).where{$_.name -like "*winutil*" -or $_.name -like "*WPF*"}
foreach ($function in $functions){
$functionDefinition = Get-Content function:\$($function.name)
$functionEntry = New-Object System.Management.Automation.Runspaces.SessionStateFunctionEntry -ArgumentList $($function.name), $functionDefinition
@ -276,7 +276,7 @@ Add-Type @"
"@
}
foreach ($proc in (Get-Process | Where-Object { $_.MainWindowTitle -and $_.MainWindowTitle -like "*titus*" })) {
foreach ($proc in (Get-Process).where{ $_.MainWindowTitle -and $_.MainWindowTitle -like "*titus*" }) {
# Check if the process's MainWindowHandle is valid
if ($proc.MainWindowHandle -ne [System.IntPtr]::Zero) {
Write-Debug "MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle) $($proc.MainWindowHandle)"
@ -392,11 +392,11 @@ Add-Type @"
# Load Checkboxes and Labels outside of the Filter fuction only once on startup for performance reasons
$filter = Get-WinUtilVariables -Type CheckBox
$CheckBoxes = $sync.GetEnumerator() | Where-Object { $psitem.Key -in $filter }
$CheckBoxes = ($sync.GetEnumerator()).where{ $psitem.Key -in $filter }
$filter = Get-WinUtilVariables -Type Label
$labels = @{}
$sync.GetEnumerator() | Where-Object {$PSItem.Key -in $filter} | ForEach-Object {$labels[$_.Key] = $_.Value}
($sync.GetEnumerator()).where{$PSItem.Key -in $filter} | ForEach-Object {$labels[$_.Key] = $_.Value}
$allCategories = $checkBoxes.Name | ForEach-Object {$sync.configs.applications.$_} | Select-Object -Unique -ExpandProperty category
@ -499,6 +499,5 @@ Version : <a href="https://github.com/ChrisTitusTech/winutil/releases/tag/$($sy
"@
Show-CustomDialog -Message $authorInfo -Width 400
})
$sync["Form"].ShowDialog() | out-null
Stop-Transcript

View File

@ -14612,4 +14612,4 @@ Version : <a href="https://github.com/ChrisTitusTech/winutil/releases/tag/$($sy
})
$sync["Form"].ShowDialog() | out-null
Stop-Transcript
Stop-Transcript