コード例 #1
0
        private IMapCompiler GetCompilerInternal()
        {
            if (_scalarMapCompilers.Count == 0)
            {
                throw MapCompilerException.NoScalarMapCompilers();
            }

            return(new MapCompiler(_scalarMapCompilers));
        }
コード例 #2
0
 public void SetConstructorFinder(IConstructorFinder finder)
 {
     if (Mapper != null)
     {
         throw MapCompilerException.MapAndCompilerSpecified();
     }
     if (ConstructorFinder != null)
     {
         throw new InvalidOperationException("Attempt to specify two constructor finders. You may only have one constructor finder per map attempt.");
     }
     ConstructorFinder = finder;
 }
コード例 #3
0
        public ConstructorInfo GetConstructor(ISpecificTypeSettings settings)
        {
            var columnNameCounts = _columnNames.ToDictionary(k => k.Key, k => k.Value.Count);
            // If there are no settings configured, the settings.Type may default to typeof(object)
            // which is clearly not what we want. If we detect that situation, fall back to
            // TargetType
            var type = settings.Type == typeof(object) || settings.Type == null ? TargetType : settings.Type;

            if (type.IsAbstract || type.IsInterface)
            {
                throw MapCompilerException.UnconstructableAbstractType(type);
            }
            return((settings.ConstructorFinder ?? BestMatchConstructorFinder.GetDefaultInstance())
                   .FindBestMatch(_context.Provider, settings.Constructor, type, columnNameCounts));
        }