Ejemplo n.º 1
0
        public String GetRegistrationName(TypeMapping typeMapping)
        {
            var namedMappingRequested = configurationDetails.IsMultimap(typeMapping.From) || configurationDetails.IsNamedMapping(typeMapping.To);
            var namedMappingRequired  = mappingBehaviors.HasFlag(MappingBehaviors.MultimapByDefault) && multimapTypes.Contains(typeMapping.From);

            return((namedMappingRequested || namedMappingRequired) ? configurationDetails.GetNamedMapping(typeMapping)
                                                                                                                                   : null);
        }
		private static void CheckForExistingNamedMapping(IUnityContainer target, TypeMapping mapping, AutomapperConfig configurationDetails)
		{
			var mappingName = configurationDetails.GetNamedMapping(mapping);
			var existingRegistration = target.Registrations
												.Where(r => String.Equals(r.Name, mappingName))
												.Where(r => r.RegisteredType.Equals(mapping.From))
												.FirstOrDefault();
			if (existingRegistration != null)
				throw new DuplicateMappingException(mapping.From, existingRegistration.MappedToType, mapping.To, mappingName);
		}
        private static void CheckForExistingNamedMapping(IUnityContainer target, TypeMapping mapping, AutomapperConfig configurationDetails)
        {
            var mappingName          = configurationDetails.GetNamedMapping(mapping);
            var existingRegistration = target.Registrations
                                       .Where(r => String.Equals(r.Name, mappingName))
                                       .Where(r => r.RegisteredType.Equals(mapping.From))
                                       .FirstOrDefault();

            if (existingRegistration != null)
            {
                throw new DuplicateMappingException(mapping.From, existingRegistration.MappedToType, mapping.To, mappingName);
            }
        }