public SqlSugarDbContext(ILogger <SqlSugarDbContext> logger, IOptions <AppSettingOption> option, ConnectionConfig config = null) { if (config == null) { if (option == null) { throw new ArgumentNullException(nameof(option)); } if (option.Value.DbContext == null) { throw new ArgumentNullException(nameof(option.Value.DbContext)); } if (string.IsNullOrEmpty(option.Value.DbContext.ConnectionString)) { throw new ArgumentNullException(nameof(option.Value.DbContext.ConnectionString)); } if (string.IsNullOrEmpty(option.Value.DbContext.ModelAssemblyName)) { throw new ArgumentNullException(nameof(option.Value.DbContext.ModelAssemblyName)); } if (string.IsNullOrEmpty(option.Value.DbContext.DbType)) { throw new ArgumentNullException(nameof(option.Value.DbContext.DbType)); } } _logger = logger; _option = option.Value; _config = config; }
/// <summary> /// Initializes new instances of dependencies that are used in this service /// </summary> /// <param name="repository">An instances of FileInfoRepository</param> /// <param name="options">An instances of IOptions<AppSettingOption></param> public FileInfoService( IEntityRepository <FileInfo> repository, IOptions <AppSettingOption> options ) : base(repository) { _options = options.Value; _repository = repository; }
static CodeGenerator() { Option = EnginContext.Current.Resolve <IOptions <AppSettingOption> >()?.Value; if (Option == null) { throw new ArgumentNullException(nameof(Option)); } var path = AppDomain.CurrentDomain.BaseDirectory; var flag = path.IndexOf("/bin"); if (flag > 0) { Delimiter = "/";//如果可以取到值,修改分割符 } path = path.Substring(0, path.IndexOf(Delimiter + "bin")); ParentPath = path.Substring(0, path.LastIndexOf(Delimiter)); }
public EntityFrameworkDbContext(IOptions <AppSettingOption> config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (config.Value.DbContext == null) { throw new ArgumentNullException(nameof(config.Value.DbContext)); } if (string.IsNullOrEmpty(config.Value.DbContext.ConnectionString)) { throw new ArgumentNullException(nameof(config.Value.DbContext.ConnectionString)); } if (string.IsNullOrEmpty(config.Value.DbContext.ModelAssemblyName)) { throw new ArgumentNullException(nameof(config.Value.DbContext.ModelAssemblyName)); } if (string.IsNullOrEmpty(config.Value.DbContext.DbType)) { throw new ArgumentNullException(nameof(config.Value.DbContext.DbType)); } _config = config.Value; }