Ejemplo n.º 1
0
        public object CreateInstance(Type interfaceType, ISqlMapper sqlMapper, 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.Build(interfaceType, sqlMapper.SmartSqlConfig, scope);

                        var obj = sqlMapper.SmartSqlConfig.ObjectFactoryBuilder
                                  .GetObjectFactory(implType, new Type[] { ISqlMapperType.Type })(new object[] { sqlMapper });
                        _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]);
        }
Ejemplo n.º 2
0
 public void Build()
 {
     var repositoryImplType = _repositoryBuilder.Build(typeof(IAllPrimitiveRepository), SqlMapper.SmartSqlConfig);
 }