Private/Build/Classes.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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# Some types/classes for use in our 'build' cmdlets # This class is used to give us a nice easy way to manage our paths for our init scripts class InitPath { # The name of the variable to be created in the _init script [string] $VariableName # The path to use for the variable in the _init script [string] $Path # When forming paths that require children these are the additional values to use [array] $ChildPaths # The description of the variable to be set in the _init script [string] $Description # When using permanent paths this is the local location to the path [string] $LocalPath # These first 2 constructors allow us to easily spin up InitPath's from objects. InitPath([pscustomobject]$InitPath) { $this.Path = $InitPath.path $this.VariableName = $InitPath.VariableName if ($InitPath.ChildPaths) { $this.ChildPaths = $InitPath.ChildPaths } if ($InitPath.Description) { $this.Description = $InitPath.Description } if ($InitPath.LocalPath) { $this.LocalPath = $InitPath.LocalPath } } InitPath([hashtable]$InitPath) { $this.Path = $InitPath.path $this.VariableName = $InitPath.VariableName if ($InitPath.ChildPaths) { $this.ChildPaths = $InitPath.ChildPaths } if ($InitPath.Description) { $this.Description = $InitPath.Description } if ($InitPath.LocalPath) { $this.LocalPath = $InitPath.LocalPath } } # Allow us to set the values by using 2 strings InitPath([string]$VariableName, [string]$Path) { $this.Path = $Path $this.VariableName = $VariableName } # Allow us to set the values by 3 strings, so we can have additional child paths if we want InitPath([string]$VariableName, [string]$Path, [array]$ChildPaths) { $this.Path = $Path $this.VariableName = $VariableName $this.ChildPaths = $ChildPaths } } |