CLSA 3.5 and Extensions Methods

CLSA 3.5 and Extensions Methods

Old forum URL: forums.lhotka.net/forums/t/3975.aspx


Brent Dunham posted on Monday, December 03, 2007

Hello All,

I have been using a custom framework partially based on the great principles within Rocky's book for several years now. I'm currently looking into .Net 3.5 and have decided to base my 3.5 framework partially on CSLA again. That being said, I've been looking through SVN and have notice a few helper classes that I thought I would inquired about for the port of CSLA to 3.5. For Instance the MethodCaller static class seems to have a few different functionalties. I think I'm going to take the methods that are appropriate and remove this class and add extension methods to the appropriate interfaces to provide the functionality. I have decided which interfaces as of yet as currently I've been Extending (in general) the 1st parameter type. I believe when the 1st parameter type is Type, I can keep these.

As an example:

Simple DataPortal has code block as follows:

// tell the business object to create its data
        MethodInfo method = MethodCaller.GetCreateMethod(objectType, criteria);
        if (criteria is int)
          MethodCaller.CallMethod(obj, method);
        else
          MethodCaller.CallMethod(obj, method, criteria);

I've extended Type with a method GetCreateMethod(object) and also extended object with methods CallMethod, so a similar code block within what I called ObjectPortal is:

<code>

MethodInfo method = objectType.GetCreateMethod(criteria);

if (criteria is int)

obj.CallMethod(method);

else

obj.CallMethod(method, criteria);

</code>

 

Sorry for the formatting.

Anyway, what I wanted to get some opinions on would be the appropriate types to extend. Type is an obvious one to me, but when it come to the actual CallMethod and CallMethodIfImplemented and GetObjectType, I've extended just object as that's what's being passed in but I'm not totally convinced this is great.Since I'm not strictly using CSLA, I can enforce using CriteriaBase and use only ICriteria for GetObjectType (heck, I may not event need it). Seems CallMethod methods could be added as an extension method to IBusinessObject. (I tend to program to interfaces).

I'm hoping to get some input as I need to move pretty fast for some major 2008 initatives.

thanks,

Brent

 

 

Copyright (c) Marimer LLC