So I’ve been working on a validation design that basically allows validation methods to be added to a list and then run. A small part of it: member x.Validate(valueToCheck:’a) = methodList |> Seq.map (fun (methodToRun) -> methodToRun(valueToCheck)) |> Seq.reduce (fun(outer) inner -> outer.MergeResults(inner)) What this is saying is take a list of methods, run them [...]
Duck Typing my way to a Universal String Convert
So being the beacon of ignorance in the fog of brilliance, I had no idea what Duck Typing was. In short it’s the idea of assuming a class’s type based on the methods it holds. Say you have 5 different classes, none of which share an inheritance tree. Now let’s say you have a method [...]
Cannot Resolve Method, Can’t Infer Return Type, and Funcs
So ran into this today and the answer was actually a lot easier to understand than I thought it would be. Say you want to order a list of objects by a number. Seems simple. Now if you have been paying attention you would know I like using Funcs. Func<SomeClass, Int32> orderByNumber = currentClass => [...]
Yeah SessionTryParse
So I got tired of seeing If Session["SomeKey"] != null… blah blah blah and thought it would be a semi worthwhile task to create a TryParse method because I’m bad like that. Not a Bad Enough Dude to Save the President, but bad. public static Boolean SessionTryParse<K>(HttpSessionState session, String key, out K itemToSet) where K [...]
Mulitple Constraint Generics and Test Base Classes
This was basically an idea I had to have test classes inherit a TestBase that has a Static Create method on it. The reason for this is that I have found it easier to have a Create method that takes care of creating a temporary class of the type the test represents. Say I have [...]