Tim’s Blog

  • Handling Persistance in Asp.Net with Dynamic Controls

    I worked on a project a couple of years ago using dynamic controls in an Asp.Net WebForms environment. Managing dynamic controls can be a real hassle. So when I read Dave Reed’s great article about Viewstate, I wondered if I could do it better now. I worked up a simple example using no Viewstate where […]

  • Passing in “this” in StructureMap

    I’ve been working with StructureMap lately, and struggled when I need to pass this in. The following code is an example of resolving that issue… namespace StateMachine { public class StateRegistry : StructureMap.Configuration.DSL.Registry { public StateRegistry () { For<IState>.Use<StateA>.Named(“FirstState”); For<IState>.Use<StateB>.Named(“SecondState”); } } public interface IStateMachine { void ChangeState(IState state); } public interface IState { void […]

  • Namespace, Encapsulation in JavaScript

    I’ve had several discussion recently some of the more advanced features of JavaScript, such as functions as return values, namespaces, encapsulation, etc. In order to demonstrate some of these things, I contrived a simple example of a dependency injection tool. Never mind that dependency injection is not really a relevant pattern in JavaScript or other […]

  • Function Name Instead of Lambda in Linq Functions

    I did not realize that functions can fill in for predicates directly without lambda notation. To illustrate, consider the following: void Main() { var words = new List<string>() { “therapists”, “s words”, “slang”, “mustache”, “sean connery” }; var s_words = words.Where(w => w.StartsWith(“s” ,StringComparison.CurrentCultureIgnoreCase)); foreach(var word in s_words) { Console.WriteLine(word); } } It works, but […]

  • MSpec “Hello World” Sample

    I’ve been working with MSpec lately. It’s a BDD framework for .Net. Here’s a hello world type example that uses Trace Writing to show a little bit about what it does. using System; using Machine.Specifications; using System.Diagnostics; namespace UnitedIndustrial.DataImportConcerns { [Subject(“Sample”)] public class SampleConcerns { static string _myString; Establish _context = () => { _myString […]

Got any book recommendations?