Skip to content

Latest commit

 

History

History

Properties-of-IDictionary

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Tricky properties of types implementing IDictionary

PowerShell dot-notation for dictionaries allows retrieval and assignment of key/value pairs as if keys were properties. It is handy but it introduces a problem for classes that implement IDictionary and have extra properties.

For example, the property ConnectionString of DbConnectionStringBuilder. Assigning it as

    $builder.ConnectionString = '...'

does not actually invokes the property setter but adds the key/value pair to the dictionary and bypasses the connection string parsing which is done by the setter.

A workaround:

    $builder.set_ConnectionString('...')

Scripts