forked from pester/Pester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTypeClass.ps1
41 lines (32 loc) · 1.1 KB
/
TypeClass.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function Is-Value ($Value) {
$Value = $($Value)
$Value -is [ValueType] -or $Value -is [string] -or $value -is [scriptblock]
}
function Is-Collection ($Value) {
# check for value types and strings explicitly
# because otherwise it does not work for decimal
# so let's skip all values we definitely know
# are not collections
if ($Value -is [ValueType] -or $Value -is [string]) {
return $false
}
-not [object]::ReferenceEquals($Value, $($Value))
}
function Is-ScriptBlock ($Value) {
$Value -is [ScriptBlock]
}
function Is-DecimalNumber ($Value) {
$Value -is [float] -or $Value -is [single] -or $Value -is [double] -or $Value -is [decimal]
}
function Is-Hashtable ($Value) {
$Value -is [hashtable]
}
function Is-Dictionary ($Value) {
$Value -is [System.Collections.IDictionary]
}
function Is-Object ($Value) {
# here we need to approximate that that object is not value
# or any special category of object, so other checks might
# need to be added
-not ($null -eq $Value -or (Is-Value -Value $Value) -or (Is-Collection -Value $Value))
}