c# - Mapping a set of properties to another set where multiple source properties may be used in conversion rules? -
I have a set of properties defined, values are all stored in the form of stars to return a new set of new properties Where the value of each new property can be in one of three ways.
- A direct copy of a specific source value.
- A default value.
- The result of some arguments applied to the values of 1 or more source properties.
My approach to this problem was to create an IMFable interface
For each method, I set an implementation of this interface with the required logic in this method.
I have a factory method based on the name of an inappropriate asset:
Private Imapable GetMapper (string localpropertyName) {char [] character = LocalpropertyNet. ToCharArray ( ); Chairs [0] = four. Touper (chairs [0]); String classname = new string (chars) + "mapping"; {Legislative assembly assembly = try assembly. GETExecutingAssembly (); Type classype = assembly GetType ("MyNamespace.Rules." + Classname, false, true); Implabel system. Activator Create instances (classotype); } Hold (System.Exception e) {// No mapper is present; New Default Mapping (LocalPropertyName); }}
Is this the best way to solve this problem?
It seems like most elegenat, but I am concerned about the performance of dynamic class loading hits.
Is it slow? Give it a profile under the test and then worry whether it is slow or not.,
Comments
Post a Comment