Monday, July 30, 2007

Updated ActiveRecord Code Generator

Today, I updated the ActiveRecord Code Generator a bit. I checked in changes to use primary and foreign key details from INFORMATION_SCHEMA. The original code used naming conventions to decide what various fields were used for - ID = Primary Key, Field_ID = Foreign Key to table Fields. If you want to use naming conventions, let me know and I can add a setting in App.Config to allow this (along with any "real" key constraints).

Labels: ,

Sunday, July 29, 2007

Hacking FireFox 2 Menus

Today, I was inspired to hack the context menu in Firefox 2.0, removing "Send To" and "Send Image". I googled for a solution, and found step-by-step directions for Firefox 1.0. So, I started digging, and the over-all instructions were good, but I only needed to comment out the menu options in browser.xul, and not touch the javascript in browser.js. The original instructions were a bit vague, but in the end, it worked!

Labels: , ,

Saturday, July 28, 2007

Castle Active Record Code Generator

Code Generation CompletedCode Generator asks about overwriting a file
I have finally released my Code Generator to Google Code as Active-Record-Gen. What does it generate? It generates ActiveRecord classes mainly, but I have used it to generate stored procedures and sys-admin scripts as well. This code generator does not (yet) generate a full Windows application project or a Mono-Rail web site, but the generated code could be used in either. In fact, with a few tweaks, this could be used to generate NHibernate "poco" and .xbm files. If you want to know more, look at the screen shots above, or head over to Google Code and run it. In my haste to make my first EXE release before supper, I forgot to add the Template directory, which should be at the same directory level as the EXE and config files. I just (1.5 hours later) uploaded a new EXE, but 2 people have already downloaded the EXE (not the source though).

As for the basic table object, it is built with the following assumptions:

Table name is plural, class name is singular.
Field "ID" is the primary key (at some point, this decision will be based on the SQL schema.
Fields ending in _ID are foreign keys (Department_ID is a foreign key to the Departments table).

Generated objects have the [ActiveRecord], [PrimaryKey], [Property], and [BelongsTo] attributes.