Skip to content

Instantly share code, notes, and snippets.

@jbogard
Created September 30, 2011 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbogard/1252482 to your computer and use it in GitHub Desktop.
Save jbogard/1252482 to your computer and use it in GitHub Desktop.
Conditional crazy
object IMappingEngineRunner.CreateObject(ResolutionContext context)
{
var typeMap = context.TypeMap;
var destinationType = context.DestinationType;
if (typeMap != null)
if (typeMap.DestinationCtor != null)
return typeMap.DestinationCtor(context.SourceValue);
else if (typeMap.ConstructDestinationUsingServiceLocator && context.Options.ServiceCtor != null)
return context.Options.ServiceCtor(destinationType);
else if (typeMap.ConstructDestinationUsingServiceLocator)
return _configurationProvider.ServiceCtor(destinationType);
else if (typeMap.ConstructorMap != null)
return typeMap.ConstructorMap.ResolveValue(context);
if (context.DestinationValue != null)
return context.DestinationValue;
if (destinationType.IsInterface)
destinationType = ProxyGenerator.GetProxyType(destinationType);
return ObjectCreator.CreateObject(destinationType);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment