Hi all,

    First of all I would like to introduce myself as this is my first
post and essentially my first time ever posting on such development
lists for open-source projects.  I would also like to take the
opportunity to thank everyone for their contributions as I've found
the Castle ActiveRecord extremely useful.

    Basically, my question/post is about attribute inheritance for the
various attributes that Castle ActiveRecord uses, like
ActiveRecordAttribute, PropertyAttribute, etc.  In my case, I am using
the component for a general framework which I use for a lot of
projects I create, which are then extended upon by 'project-specific'
classes.  To explain further, for example in a project called
'GeneralFramework' I would have a class say named 'StoreBase'.  This
would serve as the normal logic for a 'Store' which I would use in all
projects that require a 'Store' object.  Apart from that, I would have
a project-specific class library for example for a certain project
regarding a store owned by Joe, named JoeBookStore, which would have a
class named 'Store' which inherits from 'StoreBase'.  This 'Store'
class would have logic specific to what Joe wants.

    The problem I was facing with ActiveRecord was that all attributes
are NOT set as 'Inherited=true'.  Thus, if for example in general I
want all 'StoreBase' to be cached, I cant set the
ActiveRecord(Cache=Cache.ReadOnly) attribute to the 'StoreBase' as it
is not recognised by the framework, as it must be set to the 'last'
class from the inheritance chain.

    I've downloaded the source code for the framework, and updated all
attribute classes to include 'Inherited=true' in their
AttributeUsage() attribute.  This allows the attribute to be inherited
from sub-classes.  The other change I did is changed every call to
'type.IsDefined()' and type.GetCustomAttributes() to set their boolean
parameter 'inherit' to true.  This allows ActiveRecord to work even in
my case, where you have classes extending from each other, with the
Attributes being set on the base class, and not on the last class of
the inheritance-chain.  Considering that most attributes also have
'AllowMultiple=false', it allows you to 'override' the base attribute
default's by specifying a new attribute on the 'Store' class. I've
tested the change out and all test cases I tried seemed to work fine.
I cannot imagine any major changes this might do, as long as you dont
set 'AllowMultiple=true' as any duplicate inherited attributes are
overriden by the 'last' class in the chain.

     This is a minor change to the codebase, but I thought I could
share it with you maybe it would be considered for future releases, as
I don't think it has any implications and would serve useful in such
cases.  This is mainly due to the reason that ActiveRecord cannot be
configured by code (correct me if I'm wrong?), and it is only
configurable by such attributes.  Maybe there is some way to use
Fluent NHibernate together with ActiveRecord to come up with a
solution whereby you could configure such attributes by code, but use
the AR-pattern?

Thanks a lot again for every contributor's time and effort!

cheers,
Karl

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en.

Reply via email to