Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpchen committed Nov 21, 2024
1 parent 20d18df commit 6715edb
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 7 deletions.
9 changes: 9 additions & 0 deletions docs/document/Powershell/docs/Language/Array.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Array

## Creation

> [!NOTE]
> The default type of a array literal is `object[]`, you can annotate with a type.
> ```ps1
> [int[]]$foo = 1, 2, 3
> ```
21 changes: 21 additions & 0 deletions docs/document/Powershell/docs/Object Manipulation/ETS Property.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ETS Property

Extended Type System in Powershell has 4 kinds of property:

- Alias Property: An simple alias for another property.
- Script Property: Getter/Setter for a custom property that can access other members, represented as a script block.
- Note Property: An extra independent property added to the object.

## Alias Property

- Inspect Alias Property by:

```ps1
gps | gm -MemberType AliasProperty
```

- Add Alias Property by:

```ps1
```
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,14 @@ The functionality of ETS achieved benifits:

## ETS Members

To represent meta of ETS members, Powershell has an abstract class called `PSMemberInfo`, each concrete member info type is derived from it.

```cs
public abstract class PSMemberInfo { }
```


The facts of ETS members:
- each member has a type inherited from `PSMemberInfo`.

## PSObject
2 changes: 2 additions & 0 deletions docs/document/Powershell/docs/Object Manipulation/ForEach.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ If you do want a `$null` return, use `Out-Null` to swallow the value.
(gci | foreach { $_.Name | Out-Null }) -eq $null # True
```



Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Object Creation

- Create a `.NET` type instance.
- Create a `PSObject`.
- Create a `PSCustomObject`
12 changes: 5 additions & 7 deletions docs/document/Powershell/docs/Object Manipulation/Select.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ gps | select -ExpandProperty Name

> [!NOTE]
> `Foreach-Object` can achieve the same thing
```ps1
gps | foreach Name
# or use another alias of Foreach-Object %
gps | % Name
```
> ```ps1
> gps | foreach Name
> # or use another alias of Foreach-Object %
> gps | % Name
> ```
### Append Extra NoteProperty
Expand All @@ -105,8 +105,6 @@ $john = @{
$john | select Name, Age -ExpandProperty Pet
```


> [!NOTE]
> `-ExpandProperty` can only take one property.
Expand Down
3 changes: 3 additions & 0 deletions docs/document/Powershell/docs/Object Manipulation/Sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Sort


0 comments on commit 6715edb

Please sign in to comment.