The future soon

After a nice time at AKQA, I'm off in a week time to a big media company for some super duper secret WPF project I obviously won't talk about. But that means WPF content is going to re-surface en force. My WPF tips'n'tricks need to be followed on.

And thanks to the comments and emails I've received from some of the people reading me, if I've been of any help then it's all worth it.

Oh, and I bought a new high resolution MacBook Pro, fantastic Vista development machine! This one is insured though.

Ads

PowerShell arguments and encodings

Well, after fighting for an hour or two, I finally read a post explaining why my quotes were not passed around when invoking a script. Now that I'm using the -EncodedCommand attribute, everything works fine!

As the guys on the powershell team wrote about encoding conversion, I thought I'd provide two quick ones for those needing it, Url Encoding and Base64. Don't hesitate to add to your profile.

Note that I'm using LoadWithPartialName because I'm lazy and it still works on .net 2. Replace with proper LoadFrom or Load as needed.

[System.Reflection.Assembly]::LoadWithPartialName("System.Web") | out-null
function ConvertTo-UrlEncodedString([string]$dataToConvert)
{
    begin {
        function EncodeCore([string]$data) { return [System.Web.HttpUtility]::UrlEncode($data) }
    }
    process { if ($_ -as [string]) { EncodeCore($_) } }
    end { if ($dataToConvert) { EncodeCore($dataToConvert) } }
}
function ConvertFrom-UrlEncodedString([string]$dataToConvert)
{
    begin {
        function DecodeCore([string]$data) { return [System.Web.HttpUtility]::UrlDecode($data) }
    }
    process { if ($_ -as [string]) { DecodeCore($_) } }
    end { if ($dataToConvert) { DecodeCore($dataToConvert) } }
}
function ConvertTo-Base64EncodedString([string]$dataToConvert)
{
    begin {
        function EncodeCore([string]$data) { return [System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($data)) }
    }
    process { if ($_ -as [string]) { EncodeCore($_) } }
    end { if ($dataToConvert) { EncodeCore($dataToConvert) } }
}
function ConvertFrom-Base64EncodedString([string]$dataToConvert)
{
    begin {
        function DecodeCore([string]$data) { return [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($data)) }
    }
    process { if ($_ -as [string]) { DecodeCore($_) } }
    end { if ($dataToConvert) { DecodeCore($dataToConvert) } }
}

 

Technorati Tags: , , ,

Ads

WPF Attached Events Addendum

Some of you may remember my article on attached events. There's now more clarification from the WPF SDK blog. Considering the extensive email exchange I had with Wolf Schmidt about the topic and its coverage in the SDK, I wouldn't be surprised if he had something to do with that article. An excerpt from our conversation is in order.

Now that I've spent so much time on an email to one individual customer, I think I smell a WPF SDK blog entry coming :-)

The point is, the MSDN people are very accessible and very helpful, and answer with passion and accuracy. And they hang on the WPF forum as well so don't hesitate to drop your questions there.

Technorati Tags: , ,

Ads