Search
Code Better
-
Recent Posts
Categories
Category Archives: WPF
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
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 automated testing, memory leaks
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 bitwise operators, enumerations
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 app.config, web.config
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
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 assembly versions, visual studio, visual studio 2010
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 Cascade, Foreign Keys, SQL Server
Leave a comment
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 aspect-oriented programming, dependency injection, design patterns
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 enumerations, null, nullable types
Leave a comment
WPF Brushes: Solid, Gradient, Image, and More!
WPF objects take a Brush instance (an abstract class) for foreground and background colours. What is a legitimate brush, exactly? Surprisingly, it can be a solid colour, or a gradient (linear or radial); it can even be an image, or something more complicated (a compound image of sorts). The MSDN page gives the best overview of brushes, visually. Continue reading