Author Archives:
Contextual data using NHibernate filters
I’m in the middle of the development process of an application using NH for data access, and I’m faced with a requirement that could be stated as follows: The application needs to provide support for different Contexts of execution, and certain entities must be context-aware, which means that at a given time, the application only [...]
Line count in Visual Studio
This is a nice trick that should be spreaded. Select Edit -> Find & Replace -> Find in files… or just press CTRL+SHIFT+F Check Use and select Regular expressions. Type the following as the text to find: for C# ^~(:Wh@//.+)~(:Wh@\{:Wh@)~(:Wh@\}:Wh@)~(:Wh@/#).+ fore VB.NET (thanks Steve for the info!) ^~(:Wh@’.+)~(:Wh@/#).+ Select where you want to do the [...]
Polymorphic query using interfaces
Given an object model defined by the following classes/interfaces: public class Animal public interface IHasFourLegs public interface ICanFly public class Dog : Animal, IHasFourLegs public class Bird : Animal, ICanFly public class Unicorn : Animal, IHasFourLegs, ICanFly Suppose that you want to persist this class hierarchy to a database and be able to easily retrieve [...]
NHibernate Read-only property access
UPDATE: If you use the trunk you can now just do this (since rev. 3965): <property name="Total" type="Decimal" access="readonly"/> Keep reading if you are using an older version of NHibernate. Recently I’ve asked in the NHibernate mailing list about how to map a property that is calculated in the domain but needs to be persisted [...]
CompactContainer new features
Last week I’ve found this post, in which Jeff Doolittle made an analysis of some alternatives about using dependency injection with the .NET Compact Framework. As I’ve faced the same decision some time ago and ended rolling out my own solution, I pointed him to CompactContainer. Apparently he likes the project but needs some features [...]
Custom Windsor lifestyle: ResolutionContextLifestyleManager
UPDATED 27/11/2011: New implementation here For reasons that will become clear in a future post (or later in this one), I needed to implement a custom lifestyle for Microkernel/Windsor. The required behavior was to propagate an instance of a component through the whole resolution chain but no further. Let me explain it a little better. [...]
Mutually exclusive checkboxes with jQuery
I was needing a way for the user to select none or just one item in a set… here is how I’ve managed to achieve this functionality using jQuery: <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script type="text/javascript" language="javascript"> $(document).ready(function() { $(‘.mutuallyexclusive’).click(function () { checkedState = $(this).attr(‘checked’); $(‘.mutuallyexclusive:checked’).each(function () { $(this).attr(‘checked’, false); }); $(this).attr(‘checked’, checkedState); }); }); [...]
jQuery Autocomplete + JSON + ASP.NET MVC
It just took me a while to get this running, so maybe this could save you some time. The requirement was to use the jQuery Autocomplete plugin to aid in the selection of some data coming from a database in an application using ASP.NET MVC Preview 4. If you would like to see this plugin [...]
MvcContrib parameter binder’s: CastleBind vs Deserialize
I’m using MvcContrib in my first ASP.NET MVC based project… I need to get an object built from the user entry in a web form, and to simplify this task I’m trying the ”parameter binding” feature implemented in MvcContrib. I’ve tested both Deserialize and CastleBind attributes and the first big difference I’ve found between them [...]
Appending an attribute to a XML node
I just needed to append an attribute to a tag in a XML file, and it took me a while to figure it out how to do it from the command line. The “easiest” way I’ve found is using a tool called XMLStartlet. Some background… I am automating a Clickonce deployment through a nant build [...]