From 574decfde3a9c47a9cf92ac0b077f790fb29f667 Mon Sep 17 00:00:00 2001 From: Gary Woodfine Date: Fri, 23 Feb 2018 10:30:01 +0000 Subject: [PATCH] Updated Documentation --- Threenine.Map/Threenine.Map.csproj | 4 +-- docs/MapConfigurationFactory.rst | 47 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/Threenine.Map/Threenine.Map.csproj b/Threenine.Map/Threenine.Map.csproj index dd4cd5e..e971d21 100644 --- a/Threenine.Map/Threenine.Map.csproj +++ b/Threenine.Map/Threenine.Map.csproj @@ -7,14 +7,14 @@ true Three Nine Consulting Limited Gary Woodfine - https://threenine.github.io/ReflectMap/ + https://threenine.github.io/Threenine.Map/ http://static.threenine.co.uk/threeninemap_icon.png mapping AutoMapper Reflection Copyright ©2018 Three Nine Consulting Limited Reflection mapper wrapper for AutoMapper http://opensource.org/licenses/MS-PL en - https://github.com/threenine/ReflectMap + https://github.com/threenine/Threenine.Map git Breaking changes in version 1.0.2 - removed dependency on PhilosophicalMonkey. - added new Scan Method diff --git a/docs/MapConfigurationFactory.rst b/docs/MapConfigurationFactory.rst index 998b006..d38929b 100644 --- a/docs/MapConfigurationFactory.rst +++ b/docs/MapConfigurationFactory.rst @@ -43,3 +43,50 @@ Your mappings will now be available throughout your application. So now making } Will result in your Mapping being invoked + +LoadMapsFromAssemblies +---------------------- + +If speed and optimisation is a concern and you would rather explicitly pass in your assemblies containing your mapping logic you can do so, making use of the `LoadMapsFromAssemblies` +method. It accepts a `params` array of assemblies, which you can supply an unlimited assemblies to it containing your mapping logic. + +One way to do so would be to define a helper method to return an assembly by passing name to it, then retrieve the assmebly from those names +:: + + public class GetMappings + { + public void Get() + { + var domainObjects = GetAssemblyByName("DomainObjects"); + var entityObjects = GetAssemblyByName("EntityObjects"); + + MapConfigurationFactory.LoadMapsFromAssemblies(domainObjects, entityObjects); + } + + private Assembly GetAssemblyByName(string name) + { + return AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(assembly => assembly.GetName().Name == name); + } + } + + +LoadAllMappings +--------------- +If you only want to load mappings from a particular assembly then you can make use of `LoadAllMappings` making use of a smilar stategy. + +:: + + public class GetMappings + { + public void Get() + { + var domainObjects = GetAssemblyByName("DomainObjects"); + MapConfigurationFactory.LoadAllMappings(domainObjects.GetTypes()); + } + + private Assembly GetAssemblyByName(string name) + { + return AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(assembly => assembly.GetName().Name == name); + } + } +