|
|
|
@ -10,31 +10,31 @@ namespace Volo.CmsKit.Tags |
|
|
|
{ |
|
|
|
public class DefaultTagDefinitionStore : ITagDefinitionStore, ITransientDependency |
|
|
|
{ |
|
|
|
private readonly CmsKitOptions options; |
|
|
|
private readonly CmsKitTagOptions options; |
|
|
|
|
|
|
|
public DefaultTagDefinitionStore(IOptions<CmsKitOptions> options) |
|
|
|
public DefaultTagDefinitionStore(IOptions<CmsKitTagOptions> options) |
|
|
|
{ |
|
|
|
this.options = options.Value; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual Task<TagEntityTypeDefiniton> GetTagDefinitionAsync([NotNull] string entityType) |
|
|
|
public virtual Task<TagEntityTypeDefiniton> GetTagEntityTypeDefinitionsAsync([NotNull] string entityType) |
|
|
|
{ |
|
|
|
Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); |
|
|
|
|
|
|
|
var result = options.Tags.GetOrDefault(entityType) ?? throw new EntityNotTaggableException(entityType); |
|
|
|
var result = options.EntityTypes.GetOrDefault(entityType) ?? throw new EntityNotTaggableException(entityType); |
|
|
|
|
|
|
|
return Task.FromResult(result); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual Task<List<TagEntityTypeDefiniton>> GetTagDefinitionsAsync() |
|
|
|
{ |
|
|
|
return Task.FromResult(options.Tags.Values.ToList()); |
|
|
|
return Task.FromResult(options.EntityTypes.Values.ToList()); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual Task<bool> IsDefinedAsync([NotNull] string entityType) |
|
|
|
{ |
|
|
|
Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); |
|
|
|
return Task.FromResult(options.Tags.ContainsKey(entityType)); |
|
|
|
return Task.FromResult(options.EntityTypes.ContainsKey(entityType)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|