private/AdfObjectName.class.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
class AdfObjectName {
    [string] $Name
    [string] $Type

    AdfObjectName ([string] $Name, [string] $Type) 
    {
        $this.Name = $Name
        $this.Type = $Type
    }

    AdfObjectName ([string] $FullName) 
    {
        if ($FullName.IndexOf('.') -lt 1) {
            Write-Error "Expected format of name for 'FullName' input parameter is: objectType.objectName"
        }
        $parts = $FullName.Split('.')
        if ($parts[0] -notin [AdfObject]::allowedTypes ) { 
            Write-Error -Message "Unknown object type: $parts[0]."
        }
        $this.Type = $parts[0]
        $this.Name = $parts[1]
    }

}