Skip to content

Commit 9db417b

Browse files
authored
Merge pull request #305 from Icinga:feature/add_test_for_types
Feature: Add test function for add type
2 parents 25d539e + 23041ef commit 9db417b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

doc/31-Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1111

1212
[Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/15?closed=1)
1313

14+
* [#305](https://github.com/Icinga/icinga-powershell-framework/pull/305) Adds a new Cmdlet to test if functions with `Add-Type` are already present inside the current scope of the shell
15+
1416
## 1.5.2 (2021-07-09)
1517

1618
### Security Fixes
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function Test-IcingaAddTypeExist()
2+
{
3+
param (
4+
[string]$Type = $null
5+
);
6+
7+
if ([string]::IsNullOrEmpty($Type)) {
8+
return $FALSE;
9+
}
10+
11+
foreach ($entry in [System.AppDomain]::CurrentDomain.GetAssemblies()) {
12+
if ($entry.GetTypes() -Match $Type) {
13+
return $TRUE;
14+
}
15+
}
16+
17+
return $FALSE;
18+
}

0 commit comments

Comments
 (0)