how do those attributes work????

Rudolf Meier 291 Reputation points
2021-04-24T20:27:13.2+00:00

I'm producing a C++ CLI powershell cmdlet. Now... my parameters have those attributes set

[Parameter(ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]

and I want to set the "switch" attribute too... now, what I found out... the 'Parameter' seems to be the System::Management::Automation::ParameterAttribute ... so I could also write

[System::Management::Automation::ParameterAttribute(ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]

I guess... is that correct? ... if... where does this "Parameter" come from? is this some kind of typedef??

anyway... if I'm correct... then, I think what I want to do is to set a "System::Management::Automation::ParameterMetadata" attribute... but... surprise... doesn't work... this "attribute" is "not found" ... why? it's from the same assembly and it is referenced and... can someone explain me how those parameters work anyway? what's the point I'm not understanding here? ... what are the rules if a class can be used as an attribute? and... ... you know, I know nothing about this functionality... would be great to get an explanation...

thanks

.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
326 questions
0 comments No comments
{count} votes