@{
kind = 'class'
name = 'MyClass'
accessibilty = 'public'
members = @{
type = 'string'
name = 'S'
}
}
How do you consume this input? Here's an example. (Note that the code generation side is not the focal point here -- the way that we interpet the input is what matters.)
if ($input.kind = 'class') {
" $($input.accessibilty) class $($input.name) {"
$input.members | foreach {
" public $($_.type) $($_.name);"
}
" }"
}
Which generates this output:
public class MyClass {
public System.String S;
}
This approach seems most effective when you need to express a lot of attributes on a single element. The downside is that the input seems a bit verbose and unnatural in some cases.
No comments:
Post a Comment