# encoding: ascii
# api: powershell
# title: demo-attributes
# description: a demo of using some build in dotnet attributes to store some powershell METADATA (hashtables) and extract that.
# version: 0.1
# type: function
# author: karl prosser
# license: CC0
# function: demo-attributes
# x-poshcode-id: 2511
# x-archived: 2013-01-11T06:32:21
# x-published: 2013-02-17T16:01:00
#
#
function demo-attributes
{
[System.Configuration.SettingsDescription({
@{something = 1;
this = 'that';
array = (1,2,3);
sub = @{ sub1 = 1 ; sub2 =2 }
}})]
[CmdletBinding(DefaultParameterSetName="noname")]
param (
[Parameter(Position=1,mandatory = $true)]
[string]$something
)
1..10
}
$settingstext = ((dir function:\demo-attributes).scriptblock.attributes |Where-Object { $_.typeid -like '*settingsdescription*' }).description
$settingsscriptblock = $ExecutionContext.InvokeCommand.NewScriptBlock("DATA {" + $settingstext + "}")
&$settingsscriptblock