/// <summary> /// 初始化一个<see cref="TypeMetadataHandler"/>类型的新实例 /// </summary> public TypeMetadataHandler(IEntityTypeFinder entityTypeFinder, IInputDtoTypeFinder inputDtoTypeFinder, IOutputDtoTypeFinder outputDtoTypeFinder) { _entityTypeFinder = entityTypeFinder; _inputDtoTypeFinder = inputDtoTypeFinder; _outputDtoTypeFinder = outputDtoTypeFinder; }
/// <summary> /// 从程序集中刷新实体信息(实现了<see cref="IEntity{TKey}"/>接口的实体类) /// </summary> public void Initialize() { IEntityTypeFinder entityTypeFinder = _scopedServiceProvider.GetService <IEntityTypeFinder>(); Type[] entityTypes = entityTypeFinder.FindAll(true); foreach (Type entityType in entityTypes) { if (_entityInfos.Exists(m => m.TypeName == entityType.FullName)) { continue; } TEntityInfo entityInfo = new TEntityInfo(); entityInfo.FromType(entityType); _entityInfos.Add(entityInfo); } SyncToDatabase(_entityInfos); RefreshCache(); }
/// <summary> /// 从程序集中刷新实体信息(实现了<see cref="IEntity{TKey}"/>接口的实体类) /// </summary> public void Initialize() { IEntityTypeFinder entityTypeFinder = ServiceLocator.Instance.GetService <IEntityTypeFinder>(); Type[] entityTypes = entityTypeFinder.FindAll(true); foreach (Type entityType in entityTypes) { if (_entityInfos.Exists(m => m.TypeName == entityType.FullName)) { continue; } TEntityInfo entityInfo = new TEntityInfo(); entityInfo.FromType(entityType); _entityInfos.Add(entityInfo); } ServiceLocator.Instance.ExcuteScopedWork(provider => { SyncToDatabase(provider, _entityInfos); }); RefreshCache(); }
/// <summary> /// 初始化一个<see cref="EntityInfoHandlerBase{TEntityInfo,TEntityInfoProvider}"/>类型的新实例 /// </summary> protected EntityInfoHandlerBase(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; _entityTypeFinder = serviceProvider.GetService <IEntityTypeFinder>(); _logger = serviceProvider.GetLogger <TEntityInfoHandler>(); }