-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Overview | ||
|
||
- Intrinsic Members | ||
- Intrinsic Members: builtin members for all objects in PowerShell. | ||
- Extended Type System: how PowerShell append extra members over a PowerShell object. | ||
- Native Types: types always available in PowerShell. |
13 changes: 13 additions & 0 deletions
13
docs/document/Powershell/docs/Type System/Intrinsic Members.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Intrinsic Members | ||
|
||
All objects in PowerShell have five intrinsic members: | ||
|
||
- `psobject`: Reflection source of members. | ||
- `psbase`: a `MemberSet` containing members of the object being wrapped. | ||
- `psadapted`: adapted members added by ETS. | ||
- `psextended`: a `MemberSet` containing extended members **added at runtime**. | ||
- `pstypenames`: equivalent to `psobject.TypeNames`. A collection containing the type names of inheritance chain. | ||
|
||
```ps1 | ||
``` |
30 changes: 30 additions & 0 deletions
30
docs/document/Powershell/docs/Type System/Type Casting & Checking.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Type Casting & Checking | ||
|
||
## Casting | ||
|
||
Prepend a type accelerator or type name before a variable or expression. | ||
|
||
```ps1 | ||
[System.IO.FileInfo[]](gci -file) | ||
``` | ||
|
||
### Safe Casting & Convertion | ||
|
||
`-as` acts the similar as `as` in `C#`, it tries to convert object to target type, returns `$null` if failed. | ||
The left operand can be: | ||
- type name as string | ||
- type accelerator | ||
- type accelerator name as string | ||
|
||
```ps1 | ||
$foo -as [object] | ||
(Get-Date) -as 'string' # convert to date string | ||
(Get-Date) -as 'System.String' | ||
``` | ||
|
||
> [!NOTE] | ||
> All objects can be casted to `string`. | ||
## Checking | ||
|
||
`-is` and `-isnot` acts the same as `is` and `is not` in `C#`. |