Tuples Part 3 Type Inference Friendly Constructor

Last time we were left with a constructor that required us to explicitly specify generic parameters. This is not always easy or possible. We’ll now alter the script to generate a constructor which utilizes type inference to create a Tuple. In addition, all tuples will use the same overloaded method making the creation uniform.

Isynchronizeinvoke Now

ISynchronizeInvoke is an interface which allows you to execute a delegate synchronously or asynchronously. The implementer of the interface can control how the delegate is executed. In particular the implementer controls on which thread the delegate is executed. It’s common for thread sensitive objects to implement this interface. It allows consumers to execute long lived actions on a background thread and then use the ISynchronizeInvoke interface to get back onto the original thread. System.Windows.Forms.Control is a great example of this usage pattern.

Tuples Part 2 Basic Structure

Part 1 of the series outlined the basic structure of the tuple. This entry will produce a PowerShell script that will generate N tuple classes containing 1-N name value pairs.

Tuples Part 1

A tuple in computer science can be described as a set of name/value pairs. In some cases it can be described as simply a set of values that are accessible via an index 1. Previously I discussed how to create a Tuple inside of PowerShell. This series will focus on the use of Tuples in DotNet and how to use PowerShell to generate DotNet code.

  1. In this case, the index just becomes the name and hence a name/value pair. 

Ternary Reducing Code

I like my scripts to be readable and terse. They’re scripts after all and I want to get the most done with the least amount of code. There’s a lot to be said for having a readable script but I only value that when I intend to keep the script around for awhile.