Automatic type conversion with Castle ActiveRecord properties?

Use FileHelpers to import text data. Your ActiveRecord class would be decorated with both ActiveRecord and FileHelpers attributes, something like this: ActiveRecord DelimitedRecord("|") // FileHelpers class MyClass { Property // from ActiveRecord FieldConverter(ConverterKind. Date, "ddMMyyyy" ) // from FileHelpers public DateTime DateStarted {get;set;} ... }.

I have a Castle ActiveRecord class with a DateTime property. On the final assignment, behind the scenes, it would ideally check the type of date_started, and if it is DateTime, do the assignment, otherwise do Convert. I can't override accessors *, and implicit operators only work when converting to or from the containing class.

I tried extending DateTime with an implicit operator conversion, but found out it was sealed. Now I am a very unhappy dynamic programmer stuck in a statically-typed world. I could of course do the check "manually," but I am instantiating many different objects with many properties, and was hoping to be able to loop over them (using reflection), without having to give specific properties special treatment.

I could define my own custom accessors, but that again requires special treatment at assignment, since they need to be used like methods (setX(val)) and not properties (X = val). Can C# (2.0) or Castle ActiveRecord offer me any clean way to get a String -> DateTime conversion in the background?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions