New Posts New Posts RSS Feed: anything to generate the right dataconverters & verification automatically for properties
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

anything to generate the right dataconverters & verification automatically for properties

 Post Reply Post Reply
Author
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Topic: anything to generate the right dataconverters & verification automatically for properties
    Posted: 10-Oct-2008 at 9:58am
The DevForce Object mapper will, at your option, automatically generate verifiers that enforce constraints implicit in the column definitions of the backing database: e.g., it will create verifiers that enforce nullability, width, and so forth. Beyond that you must configure your own verifiers and DataConverters. 

 

>> do I need to create a Verifier (say in the Employees.GetVerifiers? or is there a better suggestion) and a DataConverter like a NumericRangeConverter in the Form, myself?

Yes, you’re right on the money.   In Employee.GetVerifiers() you would add, to the List of verifiers to be returned from the method, a verifier that would probably be a subclassed Int32RangeVerifier.  

 
In the Form code, you would create the NumericRangeConverter. If you wished to configure the ControlBindingDescriptor from scratch, it would look something like this:
 

     NumericRangeConverter converter = new NumericRangeConverter(typeof(int));

     converter.MinValue = 12;

     converter.MaxValue = 120;

     ControlBindingDescriptor descriptor = new ControlBindingDescriptor(_ageTextBox, typeof(DomainModel.Employee), "Age", converter);

     _employeesControlBindingManager.Descriptors.Add(descriptor);

 

Alternatively, you could set up your bindings using the ControlBindingManager designer, letting the designer generate all of the code for the databindings; then, in your form code, swap out the DataConverter used in the descriptor for the Age binding:

 

     ControlBindingDescriptor descriptor =

        _employeesControlBindingManager.Descriptors.Get(Employee.PathFor(e => e.Age));

     descriptor.DataConverter = converter;

 

For the record, age would probably be actually be a calculated property based on a BirthDate, so that your actual constraints would be on the BirthDate.  

 

Back to Top
Tjipke View Drop Down
Newbie
Newbie


Joined: 07-Oct-2008
Posts: 3
Post Options Post Options   Quote Tjipke Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2008 at 7:37am
Hi,

We're currently evaluating DevForce EF. And one thing I am looking at is the following 'use case'

  • Say an Employee has a property Age (just as an example)
  • Say we define that the Age is between 12 and 120
  • So we would like a verifier for that (RangeVerifier<int> I think)
  • But we would also like the dataconverter to use the MinValue and MaxValue to connect it to a spinedit


Is there anything in DevForce to automate this?
Or do I need to create a Verifier (say in the Employees.GetVerifiers? or is there a better suggestion) and a DataConverter like a NumericRangeConverter in the Form, myself?

As I said I am just getting into this DevForce stuff so I might overlook something obvious.

TIA,

Tjipke
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down