Code Better
-
Recent Posts
Categories
Category Archives: Core .NET
Rails-Style Test Database Creation in ASP.NET MVC
How can you get ASP.NET MVC to create your database on the fly for tests? Well, you can, if you use migrations for your application to build the tables, drop and recreate all the tables prior to running any tests. Continue reading
Fetching Connection Strings from App.Config in a Library via ConfigurationManager
System.Configuration.ConfigurationManager doesn’t (easily) allow you to read connection strings from an App.Config file inside a library. You need to add a few extra steps to pull this off, like using KeyValueConfigurationElement. Continue reading
Posted in Core .NET, Web, Wndows Forms
Tagged app.config, connection strings, database
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
Creating Background Applications in C#
How can you create a .NET application that runs in the background, without a console or any forms? Just create a Windows Application type application, and make sure no windows appear. That’s it! Continue reading
Debugging Silverlight Apps in Firefox
Debugging Silverlight applications in Firefox without a Web project is easy; just enable the dom.ipc.plugins.enabled configuration point in Firefox, restart your browser, and you’re ready to go! Continue reading
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
WPF Gotcha: Mouse* Event With a Backgroundless StackPanel
WPF’s StackPanel mouse events (MouseDown, MouseLeftButtonDown, and MouseRightButtonDown) don’t seem to work, even when the StackPanel is visible. That is, until you add a background of some colour and transparency. Strangely, this causes the events to fire — even though it was visible before. Continue reading