Beispiel #1
0
 public object CreateInstance(Type interfaceType, ISmartSqlMapper smartSqlMapper, string scope = "")
 {
     if (!_cachedRepository.ContainsKey(interfaceType))
     {
         lock (this)
         {
             if (!_cachedRepository.ContainsKey(interfaceType))
             {
                 if (_logger.IsEnabled(LogLevel.Debug))
                 {
                     _logger.LogDebug($"RepositoryFactory.CreateInstance :InterfaceType.FullName:[{interfaceType.FullName}] Start");
                 }
                 var implType = _repositoryBuilder.BuildRepositoryImpl(interfaceType, smartSqlMapper, scope);
                 var obj      = Activator.CreateInstance(implType, new object[] { smartSqlMapper });
                 _cachedRepository.Add(interfaceType, obj);
                 if (_logger.IsEnabled(LogLevel.Debug))
                 {
                     _logger.LogDebug($"RepositoryFactory.CreateInstance :InterfaceType.FullName:[{interfaceType.FullName}],ImplType.FullName:[{implType.FullName}] End");
                 }
             }
         }
     }
     return(_cachedRepository[interfaceType]);
 }