Como habilitar dotnet sdk no linux ubuntu:
sudo snap install dotnet-sdk --classic --channel=6.0
depois
sudo snap alias dotnet-sdk.dotnet dotnet
pode instalar também o dotnet runtime
sudo snap alias dotnet-runtime-60.dotnet dotnet
Powershell Design Patterns Prototype
Powershell Design Patterns Abstract Factory
Powershell Design Patterns Command
Powershell Design Patterns Builder
Powershell Composite Design Pattern Logger
Powershell Observer Pattern
Here weŕe going to start a series of Powershell Desing Patterns. The first one is "Chain of Resposability" pattern.
class DocumentHandler {
[DocumentHandler] $next
DocumentHandler([DocumentHandler] $next) {
$this.next = $next
}
[void] openDocument([String] $FileExtension) {
if ($null -ne $FileExtension) {
$this.next.openDocument($fileExtension);
}
}
}
class SlideshowHandler: DocumentHandler {
SlideshowHandler ([DocumentHandler] $handler) : base ($handler) {}
[void] openDocument([String] $FileExtension) {
if ("ppt" -eq $FileExtension) {
Write-Host "Opening Slideshow document..."
}
else {
([DocumentHandler]$this).openDocument($FileExtension)
}
}
}
class SpreadsheetHandler: DocumentHandler {
SpreadsheetHandler ([DocumentHandler] $handler) : base ($handler) {}
[void] openDocument([String] $FileExtension) {
if ("xlsx" -eq $FileExtension) {
Write-Host "Opening Spreadsheet document..."
}
else {
([DocumentHandler]$this).openDocument($FileExtension)
}
}
}
class TextDocumentHandler: DocumentHandler {
TextDocumentHandler ([DocumentHandler] $handler) : base ($handler) {}
[void] openDocument([String] $FileExtension) {
if ("txt" -eq $FileExtension) {
Write-Host "Opening Text document..."
}
else {
([DocumentHandler]$this).openDocument($FileExtension)
}
}
}
class Client {
static [void] Main() {
[DocumentHandler] $Chain = [SlideshowHandler]::new([SpreadsheetHandler]::new([TextDocumentHandler]::new($null)))
$Chain.openDocument("txt")
}
}
[Client]::Main()
Powershell Design Patterns Decorator ```powershell # Classe base 'Beverage' class Beverage { [string]$description = "Unkno...