Ayende @ Wiki



Rhino Commons is a set of classes that I found to be useful in more than one project. It makes use of NHibernate, Castle, and various other tidbits that I have gathered in my travels. Rhino Commons is a library to help me do advanced stuff easier, and as such, it is advanced in itself. It is not meant to present a simpler layer, mind you.


Where can I get it?

I don't have a binary distributable, but the source is accessible from https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk/ in the rhino-commons folder.

Note: the Rhino.Commons project depends on files in the /trunk/SharedLibs folder. Don't just grab the /trunk/rhino-commons content if you want to open the solution in Visual Studio or do a rebuild.


What it does?

  • Working with threads:
    • Rhino Thread Pool which allows to:
      • Cancel pending work or abort executing threads safely - WorkItem.Cancelled = true, RhinoThreadPool.Cancel(), RhinoThreadPool.CancelAll()
      • Wait for work in the thread pool to be completed - RhinoThreadPool.WaitForAllThreadsToFinish()
      • Events for starting and finishing work items - RhinoThreadPool.WorkStarted, RhinoThreadPool.WorkFinished
    • Thread Safe Queue - Generic version of a class that Udi Dahan published long ago.
    • Countdown Latch - useful for producer / consumer scenarios, where the producer wants to wait for the consumer threads to finish.

  • Working with NHibernate and Active Record:
    • Generic Respository interface
    • Expressions that combine with NHibernate Query Generator to make really natural queries
    • Unit Of Work implementation using NHibernate and Active Record (see Http Modules for implementation details)
    • PluralizingNamingStrategy - Makes it easier to get reasonable table names from the default NHibernate database generation script.
    • A quick way to delete a lot of records with NHibernate

  • With:
    • With.Transaction
    • With.Caching
    • With.PerformanceCounter

  • Http Modules:
    • Page Performance Module - Logs the time that it tooks to process a page
    • Unit Of Work Module - Correctly handle Unit Of Work in web scenarios
    • Ensure Max Number Of Queries Per Request Module - ensures that the number of queries per request is low.

  • Inversion of Control:
    • IoC Helper class that makes it easier get the container to get the services.
    • Thin wrapper around Windsor that mainly gives nicer syntax
    • Binsor - a boo configuration DSL
    • Some work on extending it to support more complex configurations

  • Local Data"
    • An implementation of a data store that is local to your current logical work (in web and non-web scenarios).

  • Logging - Mainly log4net helpers:
    • Log the current request url
    • Log the current request id
    • Appender implementation to Log4net that writes to a local embedded database, and ensure that file size doesn't get out of hand.

  • Testing:
    • Using Embedded Database for testing NHibernate / Active Record
    • Using In Memory Database for testing NHibernate / Active Record

  • Validation - Common validation methods

  • Functional programming:
    • Generic definitions to all the delegates that you are going to need
    • Simple Collection util class to handle common tasks for collections, First(), SelectAll()

  • Property Indexer:
    • C# doesn't allow indexed property, but it is pretty easy to overcome that issue.

  • Stuff that should have been in the framework:
    • SqlCommandSet that is public and can be used by people other than the ADO.Net team
    • EventArgs - not sure what the issue there was...

  • MsBuild Tasks:
    • Active Record - Create Database: Takes an Active Record assembly and a connection string, and generates the database objects required to make it work.
    • Boo task - allows to run boo code as part of the build.
    • SQL Batch Execute - Run a set of SQL Scripts.

  • Xml:
    • Easily read/write values from xml files by XPath, adapted from the MsBuild Community tasks, and mostly used to update config files in tests

ScrewTurn Wiki version 2.0 Beta. Some of the icons created by FamFamFam.