<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Scott Weinstein on .Net, Linq, PowerShell, WPF, and WCF</title><link>http://weblogs.asp.net/sweinstein/default.aspx</link><description>Scott Weinstein on .Net, Linq, PowerShell, WPF, and WCF</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><geo:lat>40.755101</geo:lat><geo:long>-73.993373</geo:long><creativeCommons:license>http://creativecommons.org/licenses/by-sa/2.0/</creativeCommons:license><image><link>http://weblogs.asp.net/sweinstein/</link><url>http://farm1.static.flickr.com/153/415763544_e3056a1bc1_o_d.png</url><title>Scott Weinstein</title></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/ScottWeinstein" type="application/rss+xml" /><feedburner:emailServiceId>ScottWeinstein</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FScottWeinstein" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FScottWeinstein" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2FScottWeinstein" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/ScottWeinstein" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FScottWeinstein" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FScottWeinstein" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FScottWeinstein" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2FScottWeinstein" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><title>When Add(ing)-Type, choose your method signatures wisely</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/1-W-KKkxVLM/when-add-ing-type-choose-your-method-signatures-wisely.aspx</link><pubDate>Fri, 08 May 2009 18:44:18 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7078825</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=7078825</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=7078825</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/05/08/when-add-ing-type-choose-your-method-signatures-wisely.aspx#comments</comments><description>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Powershell V2 has some great new features, in particular Add-Type and Remoting features are likely to be quite popular and work together without much issue. That said, there are edge cases which illustrate how the types returned from remoting calls. The following script demonstrates the issue&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;$csCode = @&amp;quot;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Demo {
    public static class D
    {
        public static int Add(int a, int b)
        {
            return a + b;
        }
        public static int AddArray(int[] ints)
        {
            return ints.Sum();
        }
        public static int AddEnumerable(IEnumerable&amp;lt;object&amp;gt; ints)
        {
            return ints.Cast&amp;lt;int&amp;gt;().Sum();
        }
        public static int AddEnumerable(IEnumerable&amp;lt;int&amp;gt; ints)
        {
            return ints.Sum();
        }
    }
}
&amp;quot;@

Add-Type -TypeDefinition $csCode -Language CSharpVersion3
$oneRemote = Invoke-Command -ComputerName localhost  -ScriptBlock { return 1 }
$listRemote = Invoke-Command -ComputerName localhost  -ScriptBlock { return (1,2,3) }
$one = &amp;amp;{return 1}
if ($one -eq $oneRemote)
{
    Write-Host &amp;quot;1 == 1&amp;quot;
}

$v =  [Demo.D]::Add($one,$oneRemote)
Write-output &amp;quot;One + OneRemote = $v&amp;quot;  ; $v=$null
$v = [Demo.D]::AddArray(($one,$oneRemote))
Write-output &amp;quot;One + OneRemote via array =  $v&amp;quot; ; $v=$null

$v = [Demo.D]::AddArray($listRemote)
Write-output &amp;quot;One + OneRemote via remote array =  $v&amp;quot; ; $v=$null

$v = [Demo.D]::AddEnumerable((1,2,3,4))
Write-output &amp;quot;One + OneRemote via local IEnumerable =  $v&amp;quot; ; $v=$null

$v = [Demo.D]::AddEnumerable($listRemote)
Write-output &amp;quot;One + OneRemote via remote IEnumerable =  $v&amp;quot;; $v=$null



$oneRemote | Get-Member&lt;/pre&gt;

&lt;p&gt;The output from the above is&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;font size="1" face="con"&gt;1 == 1 
      &lt;br /&gt;One + OneRemote = 2 

      &lt;br /&gt;One + OneRemote via array =&amp;#160; 2 

      &lt;br /&gt;One + OneRemote via remote array =&amp;#160; 6 

      &lt;br /&gt;One + OneRemote via local IEnumerable =&amp;#160; 10 # so far as expected&lt;/font&gt;&lt;/p&gt;

  &lt;p&gt;&lt;font size="1" face="con"&gt;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#ff0000" size="1" face="con"&gt;Exception calling &amp;quot;AddEnumerable&amp;quot; with &amp;quot;1&amp;quot; argument(s): &amp;quot;Specified cast is not valid.&amp;quot; 
      &lt;br /&gt;At typeDemo.ps1:49 char:29 

      &lt;br /&gt;+ $v = [Demo.D]::AddEnumerable &amp;lt;&amp;lt;&amp;lt;&amp;lt; ($listRemote) 

      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;

  &lt;p&gt;&lt;font size="1" face="con"&gt;&amp;#160;&amp;#160; TypeName: System.Int32 &lt;/font&gt;&lt;/p&gt;

  &lt;p&gt;&lt;font size="1" face="con"&gt;Name&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MemberType&amp;#160;&amp;#160; Definition&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;----&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ----------&amp;#160;&amp;#160; ----------&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;CompareTo&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Method&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Int32 CompareTo(Object value)

      &lt;br /&gt;Equals&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Method&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Boolean Equals(Object obj), System.Boolean Equals(Int32 obj)&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;GetHashCode&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Method&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Int32 GetHashCode()&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;GetType&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Method&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Type GetType()&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;GetTypeCode&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Method&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.TypeCode GetTypeCode()&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;ToString&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Method&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.String ToString()

      &lt;br /&gt;&lt;/font&gt;&lt;strong&gt;&lt;font size="1" face="con"&gt;PSComputerName&amp;#160;&amp;#160;&amp;#160;&amp;#160; NoteProperty System.String PSComputerName=localhost&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;PSShowComputerName NoteProperty System.Boolean PSShowComputerName=True&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;RunspaceId&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; NoteProperty System.Guid RunspaceId=e0dc5c05-c87d-41ad-afe0-16bc1b711f08&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What’s happening under the covers is that the PowerShell reporting infrastructure is returning a PSObject. By inspecting the type via Get-Member you can see that it has some extra NoteProperties. To PowerShell and .Net methods that expect integers and arrays of integers, the object looks and behaves like it should. But if your Add-Types use a more LINQ style approach, which expects an IEnumerable&amp;lt;T&amp;gt;, the PowerShell type system doesn’t properly convert the adapted type to its native underlying type and runtime exceptions are the result.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7078825" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=1-W-KKkxVLM:Yeh6ftdUOeo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=1-W-KKkxVLM:Yeh6ftdUOeo:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=1-W-KKkxVLM:Yeh6ftdUOeo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/1-W-KKkxVLM" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/CLR/default.aspx">CLR</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/LINQ/default.aspx">LINQ</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/05/08/when-add-ing-type-choose-your-method-signatures-wisely.aspx</feedburner:origLink></item><item><title>Some interesting sessions at the Microsoft Enterprise Developer and Solutions Conference</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/Ogu7PuKG08s/some-interesting-sessions-at-the-microsoft-enterprise-developer-and-solutions-conference.aspx</link><pubDate>Mon, 04 May 2009 17:13:55 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7071948</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=7071948</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=7071948</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/05/04/some-interesting-sessions-at-the-microsoft-enterprise-developer-and-solutions-conference.aspx#comments</comments><description>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;There are some interesting &lt;a href="http://entdevcon.telligent.com/sessions/" target="_blank"&gt;sessions at the 2009 EntDevCon&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Three of particular interest to me are are&lt;/p&gt;  &lt;p&gt;1. “Coral8 Engine Integrated with Microsoft Windows HPC Server 2008”&amp;#160; at 11 on Tuesday. &lt;/p&gt;  &lt;p&gt;I had a chance to see some of the early bits, and for anyone interesting in streaming data with high computations needs, this promises to be well worth your time. In a future post I’ll talk about how this technology can be used.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Additionally, some co-workers at &lt;a href="http://www.lab49.com/" target="_blank"&gt;Lab49&lt;/a&gt; will be presenting on Wednesday:&lt;/p&gt;  &lt;p&gt;2. &lt;a href="http://blog.lab49.com/archives/author/marcja" target="_blank"&gt;Marc Jacobs&lt;/a&gt; and Citi on “Agile Development using Low-Fidelity Prototypes, Expression Blend and SketchFlow:A Case Study” &lt;/p&gt;  &lt;p&gt;3. &lt;a href="http://blog.lab49.com/archives/author/dsimon" target="_blank"&gt;Daniel Simon&lt;/a&gt; on “Patterns and practices:composite development for WPF and Silverlight using Composite Application Guidance (a.k.a. Prism 2.0)”&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;And if I have time, I might have a few hours at the Lab49 booth, stop by to say hi.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7071948" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=Ogu7PuKG08s:lMxLrsqemP0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=Ogu7PuKG08s:lMxLrsqemP0:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=Ogu7PuKG08s:lMxLrsqemP0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/Ogu7PuKG08s" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/General+Software+Development/default.aspx">General Software Development</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/WPF/default.aspx">WPF</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/Coral8/default.aspx">Coral8</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/CEP/default.aspx">CEP</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/HPC/default.aspx">HPC</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/05/04/some-interesting-sessions-at-the-microsoft-enterprise-developer-and-solutions-conference.aspx</feedburner:origLink></item><item><title>CPU Monitoring and Alerting via Performance counters, Coral8, and PowerShell</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/gmNHql6p83I/cpu-monitoring-and-alerting-via-performance-counters-coral8-and-powershell.aspx</link><pubDate>Wed, 22 Apr 2009 03:58:09 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7055155</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=7055155</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=7055155</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/04/21/cpu-monitoring-and-alerting-via-performance-counters-coral8-and-powershell.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/powershell/default.aspx" target="_blank"&gt;The PowerShell team&lt;/a&gt; has a short post on using &lt;a href="http://blogs.msdn.com/powershell/archive/2009/04/21/v2-quick-tip-monitoring-performance-counters-with-powershell.aspx" target="_blank"&gt;V2 cmdlets to Monitor performance counters.&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Building on that, and the prior work with the PoShAdapter, here’s a sample with Coral8 and PowerShell to alert you via SMS when the rolling 30 seconds average CPU hits a threshold.&lt;/p&gt;  &lt;pre class="brush: plain; gutter: false; toolbar: false; auto-links: false; smart-tabs: false;"&gt;create VARIABLE float CPUThreashold  = 70; 
create OUTPUT STREAM fakeout SCHEMA (x string);
CREATE SCHEMA CPUSchema (cpu FLOAT);
create INPUT STREAM inCPU SCHEMA CPUSchema;
create OUTPUT STREAM highCPU SCHEMA CPUSchema;
create local STREAM avgCPU SCHEMA CPUSchema;

ATTACH OUTPUT ADAPTER smsAdapter TYPE PoShAdapter TO STREAM highCPU
PROPERTIES
    BEGINBLOCK  = [[ 
    Add-Type -AssemblyName System.Security   
    Add-Type -Path &amp;quot;C:\Program Files\Coral8\Server\bin\GmailHelper.dll&amp;quot; 
    $pass = &amp;quot;..&amp;quot;
    ]],
PROCESSBlock     = [[
 foreach ($cpuSpike in $input)
 {
  $m = &amp;quot;CPU spike at {0:0.00}&amp;quot; -f $cpuSpike['cpu']
  [RC.Gmail.GmailMessage]::SendFromGmail(&amp;quot;user&amp;quot;, $pass,&amp;quot;6465555555@tmomail.net&amp;quot;, 
   &amp;quot;Via Powershell/Coral8&amp;quot;,$m)
 }
]];

ATTACH OUTPUT ADAPTER CPUAdapter TYPE PoShAdapter TO STREAM fakeout
PROPERTIES
    RESULTSSTREAM = &amp;quot;ccl://localhost:6789/Stream/Default/MonitorCPU/inCPU&amp;quot;,
    INPUTBLOCK    = [[
Get-Counter '\Processor(*)\% Processor Time'    |
    select -expand CounterSamples               |
        ? { $_.InstanceName -eq &amp;quot;_total&amp;quot; }      | 
            % { ,,($_.CookedValue,0) } # 
]];

INSERT into avgCPU
select avg(cpu)  
from inCPU 
keep 30 SECONDS 
OUTPUT EVERY 30 SECONDS;

INSERT into highCPU 
select cpu 
from avgCPU 
WHERE cpu &amp;gt; CPUThreashold;&lt;/pre&gt;

&lt;p&gt;Yields: &lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/sweinstein/sms005_2665CC81.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="sms 005" border="0" alt="sms 005" src="http://weblogs.asp.net/blogs/sweinstein/sms005_thumb_2FC191B5.jpg" width="244" height="180" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*I lowered the threshold for testing
  &lt;br /&gt;** Yes, I should check my voice mail&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7055155" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=gmNHql6p83I:7Pi9Qoko-hg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=gmNHql6p83I:7Pi9Qoko-hg:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=gmNHql6p83I:7Pi9Qoko-hg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/gmNHql6p83I" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/Coral8/default.aspx">Coral8</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/CEP/default.aspx">CEP</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/04/21/cpu-monitoring-and-alerting-via-performance-counters-coral8-and-powershell.aspx</feedburner:origLink></item><item><title>CEP, Citi, and Coral8</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/YXqkZ4MFvvc/cep-citi-and-coral8.aspx</link><pubDate>Tue, 21 Apr 2009 03:36:16 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7051817</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=7051817</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=7051817</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/04/20/cep-citi-and-coral8.aspx#comments</comments><description>&lt;p&gt;The system I helped build at my previous job gets a nice write-up in Wall Street &amp;amp; Technology:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.wallstreetandtech.com/electronic-trading/showArticle.jhtml?articleID=216600047&amp;amp;pgno=1" target="_blank"&gt;Citi Taps CEP for Analyzing Equity Data&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I’m sure &lt;a href="http://magmasystems.blogspot.com/" target="_blank"&gt;Marc&lt;/a&gt;, &lt;a href="http://hannohinsch.com/" target="_blank"&gt;Hanno&lt;/a&gt; and the rest of the team are pleased. &lt;/p&gt;  &lt;p&gt;Congrats guys!&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7051817" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=YXqkZ4MFvvc:C9tqmeoJRLc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=YXqkZ4MFvvc:C9tqmeoJRLc:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=YXqkZ4MFvvc:C9tqmeoJRLc:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/YXqkZ4MFvvc" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/Coral8/default.aspx">Coral8</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/CEP/default.aspx">CEP</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/04/20/cep-citi-and-coral8.aspx</feedburner:origLink></item><item><title>Using Coral8 and PowerShell to receive eventing data</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/kYSyKe0OnSM/using-coral8-and-powershell-to-listen-for-wmi-events.aspx</link><pubDate>Mon, 20 Apr 2009 02:54:31 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7050360</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=7050360</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=7050360</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/04/19/using-coral8-and-powershell-to-listen-for-wmi-events.aspx#comments</comments><description>&lt;p&gt;I’ve updated the PowerShell Coral8 adapter so it can be used to receive input. Rather than demonstrate input from a database or an RSS stream, both of which can are supported by the native Coral8 adapters, I have a demo with WMI events. In this case allowing us to monitor process creation across a network.&lt;/p&gt;  &lt;p&gt;Using the same general template as &lt;a href="http://weblogs.asp.net/sweinstein/archive/2009/04/16/stream-transforms-in-coral8-via-net.aspx" target="_blank"&gt;before&lt;/a&gt; we have the following two script blocks&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;BeginBlock&lt;/strong&gt;&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;$computers = &amp;amp;{$args} localhost ccs01 ccs02
$jobs = $computers | % `
 {
   Register-WmiEvent -Class Win32_ProcessStartTrace -ComputerName $_ ` 
   -Action  { `
            $res = @{}
            $res['ProcessName'] = $args[1].NewEvent.ProcessName
            $res['ComputerName'] = $args[0].scope.Path.Server
            return $res
        }
    }&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;InputBlock&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;while ($true) 
{
    Start-Sleep -Milliseconds 100
    foreach ($p in (Receive-Job $jobs))
    {
        # Input adapter doesn't support hashtables yet
        ,,($p['ProcessName'],$p['ComputerName']) 
    }
}&lt;/pre&gt;

&lt;p&gt;And the payoff&lt;/p&gt;

&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/sweinstein/image_4B3AD90D.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="492" alt="image" src="http://weblogs.asp.net/blogs/sweinstein/image_thumb_41E1A48A.png" width="347" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7050360" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=kYSyKe0OnSM:kDiBOW2EsJE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=kYSyKe0OnSM:kDiBOW2EsJE:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=kYSyKe0OnSM:kDiBOW2EsJE:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/kYSyKe0OnSM" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/Coral8/default.aspx">Coral8</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/CEP/default.aspx">CEP</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/04/19/using-coral8-and-powershell-to-listen-for-wmi-events.aspx</feedburner:origLink></item><item><title>Stream transforms in Coral8 via .Net</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/z8OHSO9hZ_o/stream-transforms-in-coral8-via-net.aspx</link><pubDate>Fri, 17 Apr 2009 03:55:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7048601</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=7048601</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=7048601</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/04/16/stream-transforms-in-coral8-via-net.aspx#comments</comments><description>&lt;P&gt;In the first post on &lt;A href="http://weblogs.asp.net/sweinstein/archive/2009/04/12/in-process-powershell-adapter-for-coral8.aspx" target=_blank mce_href="http://weblogs.asp.net/sweinstein/archive/2009/04/12/in-process-powershell-adapter-for-coral8.aspx"&gt;integrating PowerShell and Coral8&lt;/A&gt; I showed how to create a message sink. In C#ish pseudocode we did the following:&lt;/P&gt;
&lt;P&gt;OutputStream&amp;lt;T&amp;gt;&amp;nbsp; =&amp;gt;&amp;nbsp; Action&amp;lt;T&amp;gt;&lt;/P&gt;
&lt;P&gt;where the Action&amp;lt;T&amp;gt; was a PowerShell block to send a message via GMail.&lt;/P&gt;
&lt;P&gt;Today the goal is to do a transform, something along the following&lt;/P&gt;
&lt;P&gt;OutputStream&amp;lt;T&amp;gt;&amp;nbsp; =&amp;gt;&amp;nbsp; Func&amp;lt;T,T2&amp;gt; =&amp;gt; InputStream&amp;lt;T2&amp;gt;&lt;/P&gt;
&lt;P&gt;In this example, T will be a pair of stock symbols, T2 will be a pair stock symbols along with the correlation of their log normal closing prices for the past 10 days. &lt;/P&gt;
&lt;P&gt;let’s get started.&lt;/P&gt;&lt;STRONG&gt;Coral8&lt;/STRONG&gt; &lt;PRE class="brush: plain; gutter: false; toolbar: false; auto-links: false; smart-tabs: false;"&gt;CREATE SCHEMA           StockPairSchema( SecA STRING,SecB STRING );
CREATE SCHEMA           StockPairCorrelationSchema INHERITS from StockPairSchema (CORR  FLOAT) ;
CREATE OUTPUT   STREAM  StockPairs          SCHEMA StockPairSchema;
CREATE INPUT    STREAM  StockCorrelations   SCHEMA StockPairCorrelationSchema;
ATTACH OUTPUT ADAPTER PairstoCorrelationsFunc TYPE PoShAdapter TO STREAM StockPairs
PROPERTIES
RESULTSSTREAM = "ccl://localhost:6789/Stream/Default/TestC8/StockCorrelations",&lt;/PRE&gt;
&lt;P&gt;The &lt;STRONG&gt;process block&lt;/STRONG&gt; is very simple:&lt;/P&gt;&lt;PRE class="brush: csharp; gutter: false; toolbar: false; auto-links: false; smart-tabs: false;"&gt;foreach ($t in $input)
{
    $a = Get-LogReturns $t["SecA"]
    $b = Get-LogReturns $t["SecB"]
    $c = [Demo.Stats]::Correlate($a, $b)
    ,,($t["SecA"],$t["SecB"],$c) #// double commas so the values are not flattened
}&lt;/PRE&gt;
&lt;P&gt;The block path defines the Get-LogReturns and Correlate function, so naturally it’s a bit longer. &lt;BR&gt;&lt;STRONG&gt;Get-LogReturns:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class="brush: plain; gutter: false; toolbar: false; auto-links: false; smart-tabs: false;"&gt;$wc = New-Object Net.WebClient    
function Get-LogReturns ($sec)
{
    $qry = "http://ichart.finance.yahoo.com/table.csv?s=$sec"
    $secAData = ConvertFrom-Csv $wc.DownloadString($qry) | select  -First 10 | % { $_.'Adj Close' }
    for ($i=0; $i -lt $secAData.Count-1; $i++) { [Math]::Log( $secAData[$i] / $secAData[$i+1] )  }
}&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;[Demo.Stats]::Correlate&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE class="brush: csharp; gutter: false; toolbar: false; auto-links: false; smart-tabs: false;"&gt;$csCode = @"
using System;
using System.Collections.Generic;
using System.Linq;
namespace Demo 
{
    public static class Stats
    {
        private static IEnumerable&amp;lt;TResult&amp;gt; Zip&amp;lt;TFirst, TSecond, TResult&amp;gt;(IList&amp;lt;TFirst&amp;gt; first, 
				IList&amp;lt;TSecond&amp;gt; second, 
				Func&amp;lt;TFirst, TSecond, TResult&amp;gt; func)
        {
            for (int ii = 0; ii &amp;lt; Math.Min(first.Count(),second.Count()); ii++)
                yield return func(first[ii],second[ii]);
        }
        public static double Correlate(object[] s1,object[] s2)
        {
            return Correlate(s1.Cast&amp;lt;double&amp;gt;(), s2.Cast&amp;lt;double&amp;gt;());
        }
        public static double Correlate(IEnumerable&amp;lt;double&amp;gt; s1,IEnumerable&amp;lt;double&amp;gt; s2)
        {
            var sum1 = s1.Sum();
            var sum2 = s2.Sum();
            var sumSq1 = s1.Select(v=&amp;gt; v*v).Sum();
            var sumSq2 = s2.Select(v=&amp;gt; v*v).Sum();
            var pSum = Zip(s1.ToList(),s2.ToList(), ( a, b) =&amp;gt; a*b).Sum();
            var len = s1.Count();
            var num = pSum - ((sum1 * sum2) / len);
            var denom = Math.Sqrt(((sumSq1 - (sum1 * sum1) / len) * (sumSq2 - (sum2 * sum2) / len)));
            return (denom == 0.0) ? 0 : num / denom;
        }
    }
}
"@
Add-Type -TypeDefinition $csCode -Language CSharpVersion3 -PassThru &lt;/PRE&gt;
&lt;P&gt;And in case you missed it, the correlate function isn't&amp;nbsp;in PowerShell at all, but rather coded up via in-line C# code, compiled at the startup of the adaptor, and running in the Coral8 server process.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7048601" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=z8OHSO9hZ_o:SaC4Ntd6jww:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=z8OHSO9hZ_o:SaC4Ntd6jww:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=z8OHSO9hZ_o:SaC4Ntd6jww:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/z8OHSO9hZ_o" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/CLR/default.aspx">CLR</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/Coral8/default.aspx">Coral8</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/CEP/default.aspx">CEP</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/04/16/stream-transforms-in-coral8-via-net.aspx</feedburner:origLink></item><item><title>Automatic properties in PowerShell… and how you can almost have them for your custom types</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/WWbTLpAeFYg/automatic-properties-in-powershell-and-how-you-can-almost-have-them-for-your-custom-types.aspx</link><pubDate>Tue, 14 Apr 2009 03:37:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7045681</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=7045681</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=7045681</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/04/13/automatic-properties-in-powershell-and-how-you-can-almost-have-them-for-your-custom-types.aspx#comments</comments><description>&lt;p&gt;For certain types, PowerShell has automatic properties, by this I mean PowerShell is able to inspect the object and then expose properties where normally you would need to use a string indexer.&lt;/p&gt;  &lt;p&gt;Like so:&lt;/p&gt;  &lt;pre class="brush: plain; gutter: false; toolbar: false;"&gt;$xbooks = [xml]&amp;quot;&amp;lt;Books&amp;gt;&amp;lt;Book&amp;gt;&amp;lt;Title&amp;gt;PowerShell in Action&amp;lt;/Title&amp;gt;&amp;lt;/Book&amp;gt;&amp;lt;/Books&amp;gt;&amp;quot; 
$xbooks.Books.Book.Title&lt;/pre&gt;

&lt;p&gt;Similar functionality is available for COM, WMI, ADO.Net, and AD types. It’s one of the core features of PowerShell, and its simplicity and elegance makes even diehard UNIX types sit up and take notice.&lt;/p&gt;

&lt;p&gt;But if you’re writing your own cmdlet, navigation provider, or are hosting PowerShell, and you wish to provide an adapter for your own type – you will quickly find that adapters and rest of the infrastructure for automatic properties are internal classes and unavailable to you.&lt;/p&gt;

&lt;p&gt;The best option you have is something along the following:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public PSObject CreateCustomPSObject(MyType mytype )
{
    PSObject pso = new PSObject(mytype);
    foreach (string name in MyColumnNames)     
    { 
        string getter = String.Format(&amp;quot;$this[\&amp;quot;{0}\&amp;quot;]&amp;quot;, name); 
        string setter = String.Format(&amp;quot;$this[\&amp;quot;{0}\&amp;quot;] = $value&amp;quot;, name); 
        pso.Properties.Add(new PSScriptProperty(name,                                        InvokeCommand.NewScriptBlock(getter),                                InvokeCommand.NewScriptBlock(setter))); 
    
    } 
    return pso; 
}
WriteItemObject(CreateCustomPSObject(mytype));&lt;/pre&gt;

&lt;p&gt;This will work, but the output from &lt;font size="2" face="con"&gt;get-member&lt;/font&gt; won’t be as clean as it is for a DataRow or other adapted types. Even worse, this option isn’t available at all for hosted scenarios as there no instance of CommandInvocationIntrinsics available from a Runspace or Pipleline. &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7045681" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=WWbTLpAeFYg:XY55sA2G0eU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=WWbTLpAeFYg:XY55sA2G0eU:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=WWbTLpAeFYg:XY55sA2G0eU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/WWbTLpAeFYg" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/PowerShell/default.aspx">PowerShell</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/04/13/automatic-properties-in-powershell-and-how-you-can-almost-have-them-for-your-custom-types.aspx</feedburner:origLink></item><item><title>In-process PowerShell adapter for Coral8</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/bUn2SFv-E7Q/in-process-powershell-adapter-for-coral8.aspx</link><pubDate>Sun, 12 Apr 2009 19:40:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7044722</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=7044722</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=7044722</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/04/12/in-process-powershell-adapter-for-coral8.aspx#comments</comments><description>&lt;p&gt;A few days ago a thought crept into my head; wouldn’t it be nice if I could have a Coral8 in-process adapter to run PowerShell code? If it worked it could potentially be a “universal” adapter, limiting the need for custom one-off adapters.&lt;/p&gt;  &lt;p&gt;Coral8, out-of-the-box, supports two different types of adapters. In-process adapters which must be written in C (enough said?), and out-of-process adapters which can be written in the language of your choice, but then have startup sequence, configuration, and deployment work associated with them.&lt;/p&gt;  &lt;p&gt;Using the PoShAdapter I’ve been developing, let’s take a look at the adapter as a message sink. In this case a&amp;#160; “sent to Gmail” adapter.&lt;/p&gt;  &lt;pre class="brush: plain; gutter: false; toolbar: false;"&gt;CREATE SCHEMA TSchema ( toAddr STRING , subject string, message as string); 
CREATE OUTPUT STREAM outGmail SCHEMA TSchema; 
ATTACH OUTPUT ADAPTER PoShAdapter TYPE PoShAdapter  TO STREAM outGmail  PROPERTIES          
BEGINBLOCK  = [[   
    Add-Type -AssemblyName System.Security     
    Add-Type -Path &amp;quot;C:\Program Files\Coral8\Server\bin\GmailHelper.dll&amp;quot;   
    $encPassword = &amp;quot;AQQbRXQr…kg==&amp;quot;   
    $password =[Text.Encoding]::UTF8.GetString([Security.Cryptography.ProtectedData]::UnProtect([System.Convert]::FromBase64String($encPassword),$null,&amp;quot;CurrentUser&amp;quot;))
]],
PROCESS     = [[             
    foreach ($t in $input)             
    {                  
        [RC.Gmail.GmailMessage]::SendFromGmail(&amp;quot;from.user&amp;quot;, $password,
                       $t[&amp;quot;toAddr&amp;quot;], $t[&amp;quot;subject&amp;quot;], $t[“message”])
    }
    ]];&lt;/pre&gt;

&lt;p&gt;The posh adapter, like PowerShell scripts and functions have &lt;strong&gt;begin,&lt;/strong&gt; &lt;strong&gt;process,&lt;/strong&gt; and &lt;strong&gt;end&lt;/strong&gt; blocks. &lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;beginblock&lt;/strong&gt; we load the assemblies for System.Security and GmailHelper, as well as decrypt the gmail password. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;process&lt;/strong&gt; block will have as its &lt;strong&gt;$input&lt;/strong&gt; set to a collection of the Coral8 tuples, so it simply loops through them sends out an email for each one. Because we the Runspace is kept for the lifetime of the adapter, context from the beginblock is available in the process block. &lt;/p&gt;

&lt;p&gt;In later posts I’ll explore using the PoShAdapter to transform data (as in a select or map operator), and look into the possibility of using the adapter to listen for WMI or other system events.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7044722" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=bUn2SFv-E7Q:P64aPY9SID8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=bUn2SFv-E7Q:P64aPY9SID8:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=bUn2SFv-E7Q:P64aPY9SID8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/bUn2SFv-E7Q" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/CLR/default.aspx">CLR</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/Coral8/default.aspx">Coral8</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/CEP/default.aspx">CEP</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/04/12/in-process-powershell-adapter-for-coral8.aspx</feedburner:origLink></item><item><title>Adding var args support to office integration functions with dynamic lambda expressions</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/ZKFrab4Kgk8/adding-var-args-support-to-office-integration-functions-with-dynamic-lambda-expressions.aspx</link><pubDate>Wed, 11 Mar 2009 00:00:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6952838</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=6952838</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=6952838</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/03/10/adding-var-args-support-to-office-integration-functions-with-dynamic-lambda-expressions.aspx#comments</comments><description>&lt;p&gt;Anyone who’s ever done office integration has come across a method definition like so:&lt;/p&gt;  &lt;pre class="brush: c#;nogutter;nocontrols;name="&gt;object Run(object Macro, object Arg1, object Arg2, …, object Arg30);&lt;/pre&gt;

&lt;p&gt;if you're working in VB it’s not such an issue, and rumor has it that it’s that C# 4 will also solve the problem of code such as:&lt;/p&gt;

&lt;pre class="brush: c#;nogutter;nocontrols;name="&gt;Run(“…”, Type.Missing, Type.Missing,/*28 more times*/ …, Type.Missing);&lt;/pre&gt;

&lt;p&gt;But for everyone else, you can avoid the extra typing with an extension method and dynamic lambda expressions. For example with:&lt;/p&gt;

&lt;pre class="brush: c#;nogutter;nocontrols;name="&gt;    public static class OfficeHelpers
    {
        private static MemberInfo missingMemberInfo = typeof(Type).GetMembers().Where(mi =&amp;gt; mi.Name == &amp;quot;Missing&amp;quot;).Single();
        private static MethodInfo runMethodInfo = typeof(_Application).GetMethod(&amp;quot;Run&amp;quot;);
        private static ParameterExpression macroNameParamExp = Expression.Parameter(typeof(string), &amp;quot;macroName&amp;quot;);
        private static ParameterExpression argsParamExp = Expression.Parameter(typeof(object[]), &amp;quot;args&amp;quot;);

        public static object Run(this Application App, string macroName, params object[] args)
        {
            var argsExprs = GenerateArgs(runMethodInfo, macroName, args);
            var callExpr = Expression.Call(Expression.Constant(App), runMethodInfo, argsExprs);
            var paramExprs = new ParameterExpression[] { macroNameParamExp, argsParamExp };
            var lambda = Expression.Lambda&lt;func&gt;&lt;string  , object[], object&gt;&amp;gt;(callExpr, paramExprs);
            return lambda.Compile().Invoke(macroName, args);
        }

        private static IEnumerable&amp;lt;Expression&amp;gt; GenerateArgs(MethodInfo runfuncMI, string macroName, object[] args)
        {
            yield return macroNameParamExp;
            for (int ii = 0; ii &amp;lt; args.Length; ii++)
                yield return BinaryExpression.ArrayIndex(argsParamExp, Expression.Constant(ii, typeof(int)));
            for (int ii = 0; ii &amp;lt; runfuncMI.GetParameters().Length - args.Length - 1; ii++)
                yield return Expression.MakeMemberAccess(null, missingMemberInfo);
        }&lt;/pre&gt;

&lt;p&gt;a call to &lt;/p&gt;

&lt;pre class="brush: c#;nogutter;nocontrols;name="&gt;OfficeHelpers.Run(&amp;quot;…&amp;quot;, arg1,arg2,arg3);&lt;/pre&gt;

&lt;p&gt;will generate and execute an expression like so:&lt;/p&gt;

&lt;pre class="brush: c#;nogutter;nocontrols;name="&gt;(macroName, args) =&amp;gt; RunFuncTest(macroName, args[0], args[1], args[2], Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)&lt;/pre&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6952838" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=ZKFrab4Kgk8:MseyrHdiXHM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=ZKFrab4Kgk8:MseyrHdiXHM:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=ZKFrab4Kgk8:MseyrHdiXHM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/ZKFrab4Kgk8" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/General+Software+Development/default.aspx">General Software Development</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/LINQ/default.aspx">LINQ</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/03/10/adding-var-args-support-to-office-integration-functions-with-dynamic-lambda-expressions.aspx</feedburner:origLink></item><item><title>Linq2Kdb+ Provider - source code update</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/T2_NyRXNU0E/linq2kdb-provider-source-code-update.aspx</link><pubDate>Wed, 04 Mar 2009 04:09:40 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6936969</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=6936969</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=6936969</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/03/03/linq2kdb-provider-source-code-update.aspx#comments</comments><description>&lt;p&gt;A few months ago, over the winter holiday, I put together a &lt;a href="http://weblogs.asp.net/sweinstein/archive/2009/01/04/a-linq2kdb-query-provider.aspx" target="_blank"&gt;Linq provider for the Kdb+ database&lt;/a&gt;. The folks at KX systems have graciously provided a place to host the code, which you can find at &lt;a title="https://code.kx.com/svn/contrib/sweinstein/linq2kdbplus" href="https://code.kx.com/svn/contrib/sweinstein/linq2kdbplus"&gt;https://code.kx.com/svn/contrib/sweinstein/linq2kdbplus&lt;/a&gt;. Use anonymous/anonymous for access.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;As of now the list of the unimplemented items is considerably longer than implemented features.&lt;/p&gt;  &lt;p&gt;What works&lt;/p&gt;  &lt;ul&gt;   &lt;ul&gt;     &lt;li&gt;Basic projections / &lt;strong&gt;Select&lt;/strong&gt;s (map)&lt;/li&gt;      &lt;li&gt;Basic restrictions / &lt;strong&gt;Where&lt;/strong&gt;s (filter)&lt;/li&gt;      &lt;li&gt;code generation to create strongly typed representations of a Kdb database&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;Still remaining to implemented&lt;/p&gt;  &lt;ul&gt;   &lt;ul&gt;     &lt;li&gt;Joins&lt;/li&gt;      &lt;li&gt;Orderbys&lt;/li&gt;      &lt;li&gt;Grouping&lt;/li&gt;      &lt;li&gt;Aggregates and other functions/method calls&lt;/li&gt;      &lt;li&gt;Kdb+ columns with array types&lt;/li&gt;      &lt;li&gt;Code generation support for Kdb+ user functions&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;A few notes on the code &lt;/p&gt;  &lt;li&gt;The heavy lifting of transforming the expression trees&amp;#160; done via &lt;a href="http://www.codeplex.com/IQToolkit"&gt;IQToolkit&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;The unit tests uses &lt;a href="http://www.codeplex.com/xunit"&gt;xUnit.Net&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;The code generation uses T4 and requires the &lt;a href="http://www.codeplex.com/t4toolbox"&gt;T4 Toolbox&lt;/a&gt;&lt;/li&gt;  &lt;ul&gt;   &lt;li&gt;run&amp;#160; SetupCodeGen.ps1 to have the correct paths placed in the registry &lt;/li&gt; &lt;/ul&gt;  &lt;li&gt;Linq2Kdb+ was developed on .Net 3.5SP1 and Kdb+ 2.5 - for other versions YMMV.&lt;/li&gt;  &lt;p&gt;Feedback welcome.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6936969" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=T2_NyRXNU0E:OrldAJvMLSM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=T2_NyRXNU0E:OrldAJvMLSM:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=T2_NyRXNU0E:OrldAJvMLSM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/T2_NyRXNU0E" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/Kdb_2B00_/default.aspx">Kdb+</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/03/03/linq2kdb-provider-source-code-update.aspx</feedburner:origLink></item><item><title>Dependency Injection for end-of-lifecycle clean up</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/25sPN0dLMaU/dependency-injection-for-end-of-lifecycle-clean-up.aspx</link><pubDate>Tue, 03 Mar 2009 03:03:43 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6935828</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=6935828</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=6935828</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/03/02/dependency-injection-for-end-of-lifecycle-clean-up.aspx#comments</comments><description>&lt;p&gt;The benefits of using an inversion of control container for simplifying the task of initializing an object graph have been well covered. But the benefits of using an IoC container for simplifying object cleanup are not as well publicized, and is a feature that I've grown to really like taking advantage of.&lt;/p&gt;  &lt;p&gt;The other night, &lt;a href="http://softwaredev.meetup.com/118/" target="_blank"&gt;at an Alt.Net Meetup on dependency injection/inversion of control&lt;/a&gt; I found myself being only person in the room enthusiastic about this.&lt;/p&gt;  &lt;p&gt;The core of the problem is that objects that require cleanup, (ie implement IDisposable) can infect object hierarchies -&amp;#160; any class with a has-a relationship to the IDisposable class really needs implement IDisposable itself. If you're not careful, you can easily end up with tens of classes that have the nearly-all-ceremony Dispose() methods that do nothing but cleanup their children.&lt;/p&gt;  &lt;p&gt;The cleanest solution for this problem is to move the member level containment to method level and wrap the use of the disposable in a using statement. But when that isn't a viable option the next best option is to move to dependency injection - if your class didn't create a disposable object, it can't be responsible for cleaning it up. &lt;/p&gt;  &lt;p&gt;Of course, at some point the objects do need to be disposed of,&amp;#160; in the simplest way to do that is to use a container, such as &lt;a href="http://code.google.com/p/autofac/" target="_blank"&gt;autofac&lt;/a&gt;, which supports both nested containers and object cleanup. &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6935828" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=25sPN0dLMaU:xUTv9xhOuV8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=25sPN0dLMaU:xUTv9xhOuV8:dnMXMwOfBR0"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=dnMXMwOfBR0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/ScottWeinstein?a=25sPN0dLMaU:xUTv9xhOuV8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/ScottWeinstein?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/25sPN0dLMaU" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/03/02/dependency-injection-for-end-of-lifecycle-clean-up.aspx</feedburner:origLink></item><item><title>Catalog of User Experience Patterns</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/jS1w-lU3248/catalog-of-user-experience-patterns.aspx</link><pubDate>Tue, 03 Feb 2009 13:22:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6878874</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=6878874</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=6878874</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/02/03/catalog-of-user-experience-patterns.aspx#comments</comments><description>&lt;P&gt;Via &lt;A href="http://blogs.msdn.com/brada/archive/2009/02/02/ux-patterns-explorer.aspx"&gt;&lt;FONT color=#669966&gt;Brad Abrams&lt;/FONT&gt;&lt;/A&gt;, check out this great site: &lt;A href="http://quince.infragistics.com/" target=_blank&gt;&lt;FONT color=#669966&gt;Quince: a catalog of UX design patterns&lt;/FONT&gt;&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6878874" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=VHna339z"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=wFVV4upU"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=oO426nF3"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/jS1w-lU3248" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/General+Software+Development/default.aspx">General Software Development</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/WPF/default.aspx">WPF</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/02/03/catalog-of-user-experience-patterns.aspx</feedburner:origLink></item><item><title>A Linq2Kdb+ Query provider</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/pp-t0nVGFeg/a-linq2kdb-query-provider.aspx</link><pubDate>Sun, 04 Jan 2009 10:13:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6816182</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>4</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=6816182</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=6816182</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/01/04/a-linq2kdb-query-provider.aspx#comments</comments><description>&lt;p&gt;Over the winter break I wanted to learn more about a few technologies:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&amp;#160;&lt;a href="http://msdn.microsoft.com/en-us/library/bb126445.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb126445.aspx"&gt;T4&lt;/a&gt; - the built into Visual Studio code generation tool &lt;/li&gt;    &lt;li&gt;The &lt;a href="http://kx.com/" mce_href="http://kx.com/"&gt;Kdb+&lt;/a&gt; columnar database &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb397951.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb397951.aspx"&gt;Expression trees&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p mce_keep="true"&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The result ended up in a Linq to Kdb+ query provider. The following snippet translates to&lt;/p&gt;  &lt;pre class="brush: c#;nogutter;nocontrols;name=" code?="code?"&gt;using (IConnection connection = new Connection(&amp;quot;localhost&amp;quot;, 5001))
{
    var tkc = new TestKdbContext(connection,Console.Out);
    connection.Run(@&amp;quot;\l sp.q&amp;quot;);
    IEnumerable&amp;lt;string&amp;gt; names = from row in tkc.sRecord
           where row.status == 20 &amp;amp;&amp;amp; row.city == GetCity()
           select row.name;
}     &lt;/pre&gt;

&lt;p&gt;which ends up being transformed to something like this Q function&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre&gt;{?[s;enlist (&amp;amp;;(=;`status;20);(=;`city;enlist x));();(enlist `name)!enlist `name]}&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;My thoughts - &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;T4, combined with the &lt;a href="http://www.codeplex.com/t4toolbox" mce_href="http://www.codeplex.com/t4toolbox"&gt;T4 toolbox&lt;/a&gt; proved to be a fine alternative to CodeSmith. With it I was able to generate some strongly typed classes which mapped to a Kdb tables, and also create a strongly typed KB query context.

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;Kdb+/Q is certainly an impressive technology. It combines a columnar database server and complete functional and query language in a 156kb executable. That said, getting proficient in reading Q code seems like it'll take five times as long as it will to learn to write it.
    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;Expression trees are definitely fun to play with, there's tons of opportunity in compiled lambdas for custom filtering and fine-grained entitlement checks. Creating the query provider was made possible (in the time I had) with the &lt;a href="http://www.codeplex.com/IQToolkit" mce_href="http://www.codeplex.com/IQToolkit"&gt;IQToolkit&lt;/a&gt; and this &lt;a href="http://blogs.msdn.com/mattwar/pages/linq-links.aspx" mce_href="http://blogs.msdn.com/mattwar/pages/linq-links.aspx"&gt;guide&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Update: &lt;a href="http://weblogs.asp.net/sweinstein/archive/2009/03/03/linq2kdb-provider-source-code-update.aspx" target="_blank"&gt;Source code is now available&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6816182" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=YB4ZcY2r"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=pVRNVwQ6"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=kU2wiNAb"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/pp-t0nVGFeg" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/CEP/default.aspx">CEP</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/Kdb_2B00_/default.aspx">Kdb+</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/01/04/a-linq2kdb-query-provider.aspx</feedburner:origLink></item><item><title>Creating high performance WCF services</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/OlFN1DXWTwQ/creating-high-performance-wcf-services.aspx</link><pubDate>Sun, 04 Jan 2009 01:14:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6815861</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>25</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=6815861</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=6815861</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2009/01/03/creating-high-performance-wcf-services.aspx#comments</comments><description>&lt;P&gt;I had a WCF service where I wanted to be able to support over a hundred concurrent users, and while most of the service methods had small payloads which returned quickly, the startup sequence needed to pull down 200,000 records. The out of the box WCF service had no ability to support this scenario, but with some effort I was able to squeeze orders of magnitude performance increases out of the service and hit the performance goal.&lt;/P&gt;
&lt;P&gt;Initially performance was abysmal and there was talk of ditching WCF entirely ( and as the one pushing WCF technology on the project this didn't seem like a career enhancing change ) &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's how performance was optimized. These are listed in the order they were implemented. Some are fairly obvious, others took some time to discover.&amp;nbsp; Each item represents, a significant increase in latency or scalability from the prior - and although I have internal measurement numbers, I'm not comfortable publishing them as the size of the data increased, and the testing approach changed.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Use NetTCP binding &lt;BR&gt;This helps both throughput and the time it takes to open and close connections&lt;BR&gt;
&lt;LI&gt;Use DataContract Serializer instead of XMLSerializer&lt;BR&gt;I started out using DataTables - POCO objects via Linq2Sql yielded a 6x increase&lt;BR&gt;slow: [OperationContract] MyDataTable GetData(...);&lt;BR&gt;fast: [OperationContract] IEnumerable&amp;lt;MyData&amp;gt; GetData(...);&lt;BR&gt;&lt;BR&gt;
&lt;LI&gt;Unthrottle your service &lt;BR&gt;It's quite understanable that WCF is resistant to Denial of Service attacks out of the box, but it's too bad that it's is such a manual operation to hit the "turbo button". It would be nice if the Visual Studio tooling did this for you, or at least had some guidance (MS - hint, hint) &lt;BR&gt;&lt;BR&gt;The items to look at here are: 
&lt;OL&gt;
&lt;LI&gt;&amp;lt;serviceBehaviors&amp;gt;&amp;lt;serviceThrottling ...&amp;gt; set the max values high 
&lt;LI&gt;&amp;lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&amp;gt; 
&lt;LI&gt;and under &amp;lt;netTcpBinding&amp;gt; setting the listenBacklog, maxConnections, and maxBuffer* value high&lt;BR&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;LI&gt;Cache your data&lt;BR&gt;WCF, unlike ASP.Net has no built in facility to cache service responses, so you need to do it by hand. Any cache class will do. 
&lt;LI&gt;Normalize/compress your data&lt;BR&gt;this doesn't necessarily have to be done in the database, the Linq GroupBy operators make this easy to do in code. To clarify, say your data is kept in a denormalized table&lt;BR&gt;
&lt;TABLE border=1 cellSpacing=0 cellPadding=2 width=200&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=100&gt;&lt;FONT size=1&gt;string&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=100&gt;&lt;FONT size=1&gt;Key1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=100&gt;&lt;FONT size=1&gt;string&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=100&gt;&lt;FONT size=1&gt;Key2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=100&gt;&lt;FONT size=1&gt;string&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=100&gt;&lt;FONT size=1&gt;Key3&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=100&gt;&lt;FONT size=1&gt;int&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=100&gt;&lt;FONT size=1&gt;val1&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=100&gt;&lt;FONT size=1&gt;int&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=100&gt;&lt;FONT size=1&gt;val2&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR&gt;the bulk of the result set ends up being duplicate data&lt;BR&gt;
&lt;TABLE border=1 cellSpacing=0 cellPadding=2 width=400&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;10&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;12&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;11&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;122&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;12&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;212&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;so normalize this into&lt;BR&gt;
&lt;TABLE border=1 cellSpacing=0 cellPadding=2 width=242&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;LongKeyVal3&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;BLOCKQUOTE&gt;
&lt;TABLE border=1 cellSpacing=0 cellPadding=2 width=162&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;10&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;12&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;11&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;122&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;12&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=80&gt;&lt;FONT size=1&gt;212&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;In code, given the following classes&lt;/P&gt;&lt;PRE class="brush: c#;nogutter;nocontrols"&gt;public class MyDataDenormalized
{
    public string Key1 { get; set; }
    public string Key2 { get; set; }
    public string Key3 { get; set; }
    public int Val1 { get; set; }
    public int Val2 { get; set; }
}
public class MyDataGroup
{
    public string Key1 { get; set; }
    public string Key2 { get; set; }
    public string Key3 { get; set; }
    public MyDataItem[] Values { get; set; }
}
public class MyDataItem
{
    public int Val1 { get; set; }
    public int Val2 { get; set; }
}&lt;/PRE&gt;
&lt;P&gt;you can transform an IEnumerable&amp;lt;MyDataDenormalized&amp;gt; into a IEnumerable&amp;lt;MyDataGroup&amp;gt; via the following&lt;/P&gt;&lt;PRE class="brush: c#;nogutter;nocontrols"&gt;var keyed = from sourceItem in source
           group sourceItem by new
           {
               sourceItem.Key1,
               sourceItem.Key2,
               sourceItem.Key3,
           } into g
           select g;
var groupedList = from kItems in keyed
              let newValues = (from sourceItem in kItems select new MyDataItem() { Val1 = sourceItem.Val1, Val2= sourceItem.Val2 }).ToArray()
              select new MyDataGroup()
              {
                  Key1 = kItems.Key.Key1,
                  Key2 = kItems.Key.Key2,
                  Key3 = kItems.Key.Key3,
                  Values = newValues,
              };&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;LI&gt;Use the BinaryFormatter, and cache your serializations&lt;BR&gt;If you're willing to forgo over the wire type safety, the binary formatter is the way to go for scalability. Data caching has only a limited impact if a significant amount of CPU time is spent serializing it - which is exactly what happens with the DataContract serializer.&lt;BR&gt;&lt;BR&gt;The operation contract changes to &lt;/LI&gt;&lt;PRE class="brush: c#;nogutter;nocontrols"&gt;[OperationContract]
Byte[] GetData(...);&lt;/PRE&gt;
&lt;P&gt;and the implementation to &lt;/P&gt;&lt;PRE class="brush: c#;nogutter;nocontrols"&gt;var bf = new BinaryFormatter();
using (var ms = new MemoryStream())
{
    bf.Serialize(ms, groupeList);&lt;BR&gt;    // and best to cache it too
    return ms.GetBuffer();
}&lt;/PRE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/OL&gt;
&lt;P&gt;Before items 4,5, and 6 the service would max out at about 50 clients ( response time to go way up and CPU usage would hit 80% - on a 8 core box). After these changes were made, the service could handle of 100 + clients and CPU usage flattened out at 30%&lt;/P&gt;
&lt;P&gt;Update: &lt;A href="http://blogs.microsoft.co.il/blogs/shay/" mce_href="http://blogs.microsoft.co.il/blogs/shay/"&gt;Shay Jacoby&lt;/A&gt; has reasonably suggested I show some code. &lt;/P&gt;
&lt;P&gt;Update2: Brett asks about relative impact. Here's a summary&lt;/P&gt;
&lt;TABLE border=1 cellSpacing=0 cellPadding=2 width=369&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=132&gt;item&lt;/TD&gt;
&lt;TD vAlign=top width=121&gt;latency&lt;/TD&gt;
&lt;TD vAlign=top width=114&gt;scalability&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=143&gt;2) DataContract Serializer&lt;/TD&gt;
&lt;TD vAlign=top width=128&gt;large&lt;/TD&gt;
&lt;TD vAlign=top width=119&gt;large&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=146&gt;3) unthrottle&lt;/TD&gt;
&lt;TD vAlign=top width=129&gt;small&lt;/TD&gt;
&lt;TD vAlign=top width=121&gt;large&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=147&gt;4) cache data&lt;/TD&gt;
&lt;TD vAlign=top width=128&gt;small&lt;/TD&gt;
&lt;TD vAlign=top width=122&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=147&gt;5) normalize data&lt;/TD&gt;
&lt;TD vAlign=top width=128&gt;medium&lt;/TD&gt;
&lt;TD vAlign=top width=123&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=147&gt;6) cache serialization&lt;/TD&gt;
&lt;TD vAlign=top width=128&gt;small&lt;/TD&gt;
&lt;TD vAlign=top width=123&gt;large&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;A href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fweblogs.asp.net%2fsweinstein%2farchive%2f2009%2f01%2f03%2fcreating-high-performance-wcf-services.aspx"&gt;&lt;IMG border=0 alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fweblogs.asp.net%2fsweinstein%2farchive%2f2009%2f01%2f03%2fcreating-high-performance-wcf-services.aspx"&gt;&lt;/A&gt; &lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6815861" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=WSNRS1bq"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=MrSL0NHm"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=BE1AMw2q"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/OlFN1DXWTwQ" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/General+Software+Development/default.aspx">General Software Development</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/WCF/default.aspx">WCF</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2009/01/03/creating-high-performance-wcf-services.aspx</feedburner:origLink></item><item><title>Adding users to a distribution list, in bulk</title><link>http://feedproxy.google.com/~r/ScottWeinstein/~3/uXRsk78uyo0/adding-users-to-a-distribution-list-in-bulk.aspx</link><pubDate>Thu, 18 Dec 2008 23:59:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6796184</guid><dc:creator>Scott Weinstein</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://weblogs.asp.net/sweinstein/rsscomments.aspx?PostID=6796184</wfw:commentRss><wfw:comment>http://weblogs.asp.net/sweinstein/commentapi.aspx?PostID=6796184</wfw:comment><comments>http://weblogs.asp.net/sweinstein/archive/2008/12/18/adding-users-to-a-distribution-list-in-bulk.aspx#comments</comments><description>&lt;P&gt;If you've every had to add more then two users to a distribution list in outlook you know just how painful the modal dialogs can be.&lt;/P&gt;
&lt;P&gt;Doing it in bulk is easy, if you have the right tools (and assuming you are the owner or co-owner of the group).&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;A href="http://weblogs.asp.net/sweinstein/archive/tags/PowerShell/default.aspx" target=_blank mce_href="http://weblogs.asp.net/sweinstein/archive/tags/PowerShell/default.aspx"&gt;PowerShell&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.quest.com/powershell/activeroles-server.aspx" target=_blank mce_href="http://www.quest.com/powershell/activeroles-server.aspx"&gt;PowerShell Commands for Active Directory&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;a list of users you want to add&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;In this example, I have my list of users in a text file, but it could come from a DB, feed, or other distribution list.&lt;/P&gt;
&lt;P&gt;The "script" is all of two lines long: &lt;/P&gt;&lt;PRE class=csharpcode&gt;&amp;gt; $users = cat users.txt | Get-QADUser
&amp;gt; Get-QADGroup &amp;lt;groupName&amp;gt; |  Add-QADGroupMember  -member $users&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;How great is that?&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6796184" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=1fkYjQKh"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=6zj3m8Qv"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/ScottWeinstein?a=vPGDJ6qt"&gt;&lt;img src="http://feeds.feedburner.com/~f/ScottWeinstein?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/ScottWeinstein/~4/uXRsk78uyo0" height="1" width="1"/&gt;</description><category domain="http://weblogs.asp.net/sweinstein/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/sweinstein/archive/tags/PowerShell/default.aspx">PowerShell</category><feedburner:origLink>http://weblogs.asp.net/sweinstein/archive/2008/12/18/adding-users-to-a-distribution-list-in-bulk.aspx</feedburner:origLink></item></channel></rss>
