Class TemplateService
Represents a service for managing templates.
Implements
Inherited Members
Namespace: DataWeb.Templating
Assembly: DataWeb.Core.dll
Syntax
public class TemplateService : ITemplateService
Remarks
Initializes a new instance of the TemplateService class.
Constructors
TemplateService(ITemplateStore)
Represents a service for managing templates.
Declaration
public TemplateService(ITemplateStore templateStore)
Parameters
Type | Name | Description |
---|---|---|
ITemplateStore | templateStore | The template store to use for retrieving and saving templates. |
Remarks
Initializes a new instance of the TemplateService class.
Methods
ConvertStatus(string)
Converts the given value to a template status.
Declaration
public TemplateStatus ConvertStatus(string value)
Parameters
Type | Name | Description |
---|---|---|
string | value |
Returns
Type | Description |
---|---|
TemplateStatus |
GetTemplateAsync(TemplateFilter, CancellationToken)
Gets a template matching the specified filter.
Declaration
public Task<Template> GetTemplateAsync(TemplateFilter filter, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
TemplateFilter | filter | The TemplateFilter to apply to the templates. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Template> | The template matching the specified filter, or null if no match was found. |
GetTemplateContextsAsync(CancellationToken)
Gets all the distinct template contexts in the system.
Declaration
public Task<IEnumerable<string>> GetTemplateContextsAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IEnumerable<string>> | A list of all the distinct template contexts in the system. |
GetTemplateCountAsync(TemplateFilter, CancellationToken)
Gets the count of templates matching the specified filter.
Declaration
public Task<long> GetTemplateCountAsync(TemplateFilter filter, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
TemplateFilter | filter | The TemplateFilter to apply to the templates. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<long> | The count of templates matching the specified filter. |
GetTemplatesAsync(TemplateFilter, CancellationToken)
Gets the templates matching the specified filter.
Declaration
public Task<IEnumerable<Template>> GetTemplatesAsync(TemplateFilter filter, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
TemplateFilter | filter | The TemplateFilter to apply to the templates. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IEnumerable<Template>> | The templates matching the specified filter. |
RemoveTemplateAsync(string, CancellationToken)
Removes the template with the specified Id.
Declaration
public Task RemoveTemplateAsync(string id, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | id | The Id of the template to remove. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
SetTemplateAsync(Template, CancellationToken)
Sets the specified template in the store.
Declaration
public Task SetTemplateAsync(Template template, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Template | template | The Template to set in the store. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |