FieldDataManager doesn't expose GetFieldData

FieldDataManager doesn't expose GetFieldData

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


bt1 posted on Wednesday, January 07, 2009

   I was reading the C# 2008 book ch7 pg257.  Where it talks about creating your own implementations of IFieldData<T> and PropertyInfo<T> and storing the Original value in a custom FieldData object.

I am trying to automate the creation of a user readable audit of the properties changed on an object.  We currently create an audit like this: Changed friendlyname Old: originalvalue, New: currentvalue.  This audit is saved to a DB.

I subclassed BusinessBase and would like to add an audit method that loops all managed fields and gets their IFieldData objects.  I could then check if the IFieldData is my custom FieldData type that would have the Original and Current value.  I then could create the Audit from this information.

The problem I am having is getting access to the FieldData objects.  GetFieldData's access modifier is internal and my custom BusinessBase is not in the Csla assembly.

The ability to use the field manager/managed fields avoids use of reflection for performance.  It also allows me to selectivly specify which properties should be audited by using the standard PropertyInfo<T> or the custom PropertyInfo class that overrides NewFieldData. 

rsbaker0 replied on Wednesday, January 07, 2009

I ran into this exact same issue with my own custom IFieldData type. For the time being, I just changed my copy of CSLA so that GetFieldData is public rather than internal. It's not the best solution, but I don't see another good way around it.

 

RockfordLhotka replied on Wednesday, January 07, 2009

I didn't make it public because it opens a vector for abuse. Maybe that possibility is worth the benefit?

JoeFallon1 replied on Thursday, January 08, 2009

It sounds like it is worth it. I built custom FieldData and PropertyInfo subclasses as a test but did not take it one step further like bt1 and rsbaker0 did. They want to make use of this data in their custom BusinessBase class which makes perfect sense. So if the first 3 users who try to implement custom FieldData need this functionality then I think it should be made Public.

Joe

 

bt1 replied on Thursday, January 08, 2009

The ability to loop through the managed properties and leveraging reusable methods from a base class is awesome.

  Would a good solution be for me to edit my copy of the CSLA by adding protected method to BusinessBase that wraps FieldManager.GetFieldData(propertyInfo) similar to ReadProperty but returning IFieldData vs the value?

protected Csla.Core.FieldManager. IFieldData ReadFieldData( IPropertyInfo propertyInfo)

   return  FieldManager.GetFieldData(propertyInfo); 
}

JoeFallon1 replied on Thursday, January 08, 2009

That is a good *temporary* solution.

One of the goals should be to never have to modify the Csla framework itself to simplify upgrading in the future.

So hopefully Rocky will agree to add something like your solution to the framework.

Joe

 

bt1 replied on Thursday, January 08, 2009

Does anyone know if Rockey argrees to add this, how long does it take to show up in a release?

RockfordLhotka replied on Friday, January 09, 2009

It depends on several factors, including how busy I am (these first two weeks of January are very busy), how many other bugs/issues there are and the priority of them (bugs usually win over change requests), and how much time/effort is required to analyze/design/test/code the changes.

Right now my time is limited, and there are some bugs that are more important than this change request. I'm hoping to do a 3.6.1 beta release by the end of January, and I'll certainly try to fit this in there if I can.

Copyright (c) Marimer LLC