Stephanevg / PSClassUtils

A set of utilities to work with Powershell Classes
http://powershelldistrict.com/how-to-generate-a-uml-diagram-using-powershell/
91 stars 23 forks source link

Add `[object]` for properties where the type is not specified #111

Open Stephanevg opened 5 years ago

Stephanevg commented 5 years ago

In this example, the $Prefix Property has no type specified. Theoratically, this means that the property can accept anything (basically, anything that is a descendant of type Object)

Class Computer { $Prefix [int]$Number [String]$FullName

Computer(){}

Computer([Int]$Number){
    $this.SetName($Number)
}

[String] SetName([int]$Number){
    $this.Number = $Number
    $this.FullName = "$($this.Prefix)-{0:0000}" -f $Number
    return $this.GetfullName()
}

[String]GetFullName(){
    return $this.FullName
}

}

Class Server : Computer { $Prefix = 'SRV'

Server($Number){
    $this.SetName($Number)
}

}

Class Laptop : Computer { $Prefix = 'LPT'

Laptop($Number){
    $this.SetName($Number)
}

}



This is what it looks like:

![image](https://user-images.githubusercontent.com/6302961/61353131-53117500-a86f-11e9-9ce5-e9923ebafb48.png)

The `[]` in front of the $Prefix property should not be empty like that, but filled with the word `Object`