PoshCode Archive  Artifact [472cb7adb9]

Artifact 472cb7adb94fe3cf3ee117aa6e7f62fffa69ee09f74d5197fcd571b20451539f:

  • File Set-AttachedProperty.ps1 — part of check-in [d9ba5470bc] at 2018-06-10 12:56:16 on branch trunk — A piece that’s missing from PoshCode 0.01 (user: unknown size: 1175)

# encoding: ascii
# api: powershell
# title: Set-AttachedProperty
# description: A piece that’s missing from PoshCode 0.01
# version: 0.1
# type: function
# license: CC0
# function: Set-AttachedProperty
# x-poshcode-id: 1017
# x-archived: 2009-04-16T01:36:33
#
#
#function Set-AttachedProperty {
[CmdletBinding()]
PARAM(
   [Parameter(Position=0,Mandatory=$true)
   [System.Windows.DependencyProperty]
   $Property
,
   [Parameter(Mandatory=$true,ValueFromPipeline=$true)
   $Element
)
DYNAMICPARAM {
   $paramDictionary = new-object System.Management.Automation.RuntimeDefinedParameterDictionary
   $Param1 = new-object System.Management.Automation.RuntimeDefinedParameter
   $Param1.Name = "Value"
   # $Param1.Attributes.Add( (New-ParameterAttribute -Position 1) )
   $Param1.Attributes.Add( (New-Object System.Management.Automation.ParameterAttribute -Property @{ Position = 1 }) )
   $Param1.ParameterType = $Property.PropertyType
           
   $paramDictionary.Add("Value", $Param1)
   
   return $paramDictionary
}
PROCESS {
   $Element.SetValue($Property, $Param1.Value)
   $Element
}
#}
#New-Alias sap Set-AttachedProperty