"how to write a converter class? how to efficiently write mapping rules?" Code Answer


what i have done to solve this problem:

  1. wrote a bimap (with the help of older sos on that issue).

  2. inserted the mapping into it (all value combinations in key, the resulting key in the "value", together with a bitarray which specifies the indices of the string that are defined by that mapping.

  3. wrote some code to calculate a resulting overall string from it, as the mapping will just give partial strings.

  4. the one-to-one mappings were trivial.

that way i could use the mappings in both ways. given a string, i still have a quite expensive search (as i have to compute the stored string utilizing the bitarray as a mask)

at the moment it seems to work very good, but i'm not finished yet.

thank you all for your very good ideas and approaches! perhaps automapper can do this, but i do not have much time at the moment to read and try out a new technology.

if anybody can provide some relevant examples on how to do this on automapper, i will accept it as an answer (as i already love automapper).

examples like lets say: 3 enums with 5 values to one fixed length string one fixed length string to 3 enum with 5 values (the reverse of the above).

as an example:

a.a && b.o && c.y ==> "**a**********************"
a.a && b.p && c.y ==> "**b**********************"
a.b && b.o && c.y ==> "*****x*******************"
a.b && b.o && c.z ==> "*****w*******************"

can automapper achieve such things?

By TheBinaryhood on May 19 2022

Answers related to “how to write a converter class? how to efficiently write mapping rules?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.