How much does Linq.Take take?

17 Apr 2009 I wasn’t 100% certain how much the “Take” would take from a list with less elements than the number you want to take. It probably says in the docs, but let me assure you that this test succeeds: [Test] public void TakeTakesAsMuchAsThereIs() { string[] stuff = {"hi"}; var l =...

Scary StructureMap configuration expressions Pt.1

07 Apr 2009 “Most scary StructureMap Configuration Expression”™ so far… ForRequestedType() .InterceptConstructionWith(wcfCachePolicy) .AddInstances(instanceExpression => instanceExpression.Conditional( cond => { cond.TheDefault.Is.ConstructedBy( ctx => ctx.GetInstance() .OpenSession( new IsisNHInterceptor(ctx.GetInstance()))); cond.If(ctx => ctx.ParentType.Name.Contains("ReadOnly")).ThenIt.Is. ConstructedBy( ctx =>ctx.GetInstance().OpenSession()); })); </csharp> The idea: In order to correctly talk to a decidedly legacy-i Database correct, write operations need to set a number...

Comfortable command line argument parsing

27 Mar 2009 Once in a while you may want to write a command line tool which may have to accept commad line arguments. In comes a nice little bit of source code that is part of the great output of the Mono project. Documentation is available here and the source code can...

cycling through a number range

11 Mar 2009 What I really wanted to do was to play a round of quakelive. But right now, quakelive is down (well, it’s Beta, isn’t it?). Quakelive pointed me to their twitter feed. Next I wondered what other people are suffering from this outage and went to twitterfall, doing a search on...

Another beacon in a sea of expressions

07 Mar 2009 A prosaic introduction to the subject of .NET expressions. These were introduced with .NET 3.5 and are featured most prominently in LINQ. Over here I implemented a use case with the aid of expressions. In my current project I am using expressions to be able to analyze what the user...