Category Archives: WPF

Windows Presentation Foundation-based desktop applications

Mocking Base Class Methods with Moq

Moq does allow you to mock base class methods, via the use of the Moq.Protected namespace. You can read about it here. Imagine you have the following scenario: class Animal { private int timesTalked = 0; public void Talk() { … Continue reading

Posted in Libraries, Web, Wndows Forms, WPF | Tagged | Leave a comment

Deserializing to Dynamic with RestSharp

You can use JSON.NET to convert any RestSharp service response to a list of dynamic instances; you just need a bit of plumbing code to do it. Continue reading

Posted in Libraries, Silverlight, Web, Wndows Forms, WPF | Tagged , | 6 Comments

Writing Automated Performance Tests

I found a memory leak in my application, and wrote an automated test using GC.GetTotalMemory to tell if objects were leaking or not. They were (20MB of them in 100k instances). Continue reading

Posted in Core .NET, Silverlight, Wndows Forms, WPF | Tagged , | Leave a comment

Using Enumerations as Bit Flags

You can use enumerations as bit flags. The FlagsAttribute is optional; more importantly, you need to assign powers of 2^n to the enum’s values. Depending on the .NET version, checking can be easy (.HasFlag) or hard (bitwise AND operation) Continue reading

Posted in Core .NET, Silverlight, Web, Wndows Forms, WPF | Tagged , | Leave a comment

Storing a String List in App.Config or Web.Config

How can you store a list of strings (or ints, say) into a single appSetting key/value pair? Surprisingly, it’s as easy as using a delimited list (like comma-delimited or semicolon-delimited) and splitting it at runtime. Continue reading

Posted in Core .NET, Silverlight, Web, Wndows Forms, WPF | Tagged , | Leave a comment

Procedure Expects Parameter Which Was Not Supplied

SqlCommand’s Parameters prevent SQL injection attacks. Surprisingly, when passed in a null value, you get the exception: Procedure or function “…” expects parameter ‘@foo’, which was not supplied. Continue reading

Posted in Core .NET, Web, Wndows Forms, WPF | Tagged , , | Leave a comment

Visual Studio Automatic Version Numbering

Visual Studio (2010+) allows you to specify that it should generate (incremental) build versions for your projects. The syntax is quite simple (for AssemblyInfo.cs), but there are a few caveats to know. Continue reading

Posted in Silverlight, Tools, Web, Wndows Forms, WPF | Tagged , , | Leave a comment

Finding Circular Dependencies in SQL Server

SQL Server doesn’t allow a cycle of foreign keys, nor two or more paths to cascadingly delete rows from a table. Thankfully, there’s a script you can use to detect at least table reference cycles. Continue reading

Posted in Libraries, Web, Wndows Forms, WPF | Tagged , , | 3 Comments

Using NInject For Compile-Time AOP

An update to my aspect-oriented design pattern for compile-time checking: you can implement aspects as interfaces with singular implementations, and use Ninject to inject the interface implementations. Smooth, easy, and it works! Continue reading

Posted in Core .NET, Silverlight, Web, Wndows Forms, WPF | Tagged , , | Leave a comment

Enums, SQL Server, and Null

Ever wonder how to deal with enumerations that might be null? Should you have a “nothing” value? What about SQL Server? As it turns out, enumerations are value types (often represented by integers), which means that they can be nullable! Continue reading

Posted in Core .NET, Silverlight, Web, Wndows Forms, WPF | Tagged , , | Leave a comment