/// <summary>
        /// Builds the mapper. MapsWith attribute takes priority over InferMappingFor. Also, multiple mapping attributes are currently unsupported.
        /// </summary>
        /// <param name="descriptor">The descriptor.</param>
        protected virtual void BuildMapper(ControllerDescriptor descriptor)
        {
            var mapperAttribute = descriptor.ControllerType.GetCustomAttributes(typeof (MapsWithAttribute), false) as MapsWithAttribute[];
            if (mapperAttribute != null && mapperAttribute.Length == 1)
            {
                mapper = Activator.CreateInstance(mapperAttribute[0].MapperType) as EntityMapperBase;

                if (mapper != null)
                {
                    MapperRepository.Instance.RegisterMapper(mapper);
                    return;
                }
            }

            var inferredAttribute = descriptor.ControllerType.GetCustomAttributes(typeof(InferMappingForAttribute), false) as InferMappingForAttribute[];
            if (inferredAttribute != null && inferredAttribute.Length == 1)
            {
                var mapperType =
                    typeof (EntityMapper<,>).MakeGenericType(new Type[]
                                                                 {
                                                                     descriptor.ControllerType as Type,
                                                                     inferredAttribute[0].TargetType
                                                                 });
                mapper =
                    Activator.CreateInstance(mapperType) as EntityMapperBase;

                // configure the mapper based on the strict flag.
                if (inferredAttribute[0].Strict)
                    mapper.InferStrictOnly();
                else
                    mapper.InferOnly();

                MapperRepository.Instance.RegisterMapper(mapper);
            }
        }