Hi folks, since a long time I have to publish this project and I finally got the time to release a beta version of it. The purpose of this project is to provide a simple framework component to easily map object from different types. A simple example is given just below. For now the project is still in pre beta version, unit tests are not yet published and documentation is not published too. But this little piece of code is really easy to use and really easy to understand.
The project is actually hosted on codeplex and available at this address : http://mappingfm.codeplex.com/
Here’s a simple example of the mapping framework usage.
class Program { static void Main(string[] args) { // Initialize the mappers with the given assemblies in the app.config // They will be inspected and their dependencies too. (configurable) MappingFrameworkBoostraper.Initialize(); // Just check if TestMapper is registred in the mapper service bool isMapperRegistred = MapperService.Instance.IsMapperExisting(new MappingTuple(typeof(int), typeof(string))); string mappingResult = String.Empty; // If he's registred, try to map an integer to a string which is the mapping implemented by TestMapper if(isMapperRegistred) mappingResult = MapperService.Instance.Map<int, string>(10); // Display the result (and cross the fingers) Console.WriteLine("Mapper registred : {0}{1}{2}", isMapperRegistred, Environment.NewLine, mappingResult); Console.ReadKey(); } } /// <summary> /// Convert integer to string /// </summary> [TypeMapper(typeof(int), typeof(string))] public class TestMapper : IMapper { public object Map(object source) { int sourceObject = (int)source; return sourceObject.ToString(); } }
Project link : http://mappingfm.codeplex.com/