Interface IAnnotationRepository
Represents a local cache of topics for a specific scene. Allows CRUD operations and monitoring.
Namespace: Unity.Cloud.Annotation
Syntax
public interface IAnnotationRepository
Methods
CreateTopicAsync(ITopicCreation)
Creates and adds an ITopic to the repository.
Declaration
Task<ITopic> CreateTopicAsync(ITopicCreation topicCreation)
Parameters
| Type | Name | Description |
|---|---|---|
| ITopicCreation | topicCreation | The ITopicCreation object that contains the necessary information to create the new topic. |
Returns
| Type | Description |
|---|---|
| Task<ITopic> | A task whose result is the created topic. |
Examples
async Task<ITopic> CreateTopic(string title, string description)
{
// Creates and populates a TopicCreation request object.
var topicCreation = new TopicCreation()
{
// Populate all desired fields.
Title = title,
Description = description
};
// Sends the request to the repository and waits for the created topic.
var createdTopic = await m_AnnotationRepository.CreateTopicAsync(topicCreation);
return createdTopic;
}
DeleteTopicAsync(Guid)
Removes an ITopic from the repository.
Declaration
Task DeleteTopicAsync(Guid topicId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | topicId | The ID of the topic you want to delete. |
Returns
| Type | Description |
|---|---|
| Task | A task with no result. |
Examples
async Task DeleteTopic(Guid topicId)
{
// Delete a specific topic in the repository.
await m_AnnotationRepository.DeleteTopicAsync(topicId);
}
GetTopicAsync(Guid)
Returns the ITopic for the specific ID from the repository. Returns null if the ITopic does not exist.
Declaration
Task<ITopic> GetTopicAsync(Guid topicId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | topicId | The ID of the topic to get. |
Returns
| Type | Description |
|---|---|
| Task<ITopic> | A task whose result is the fetched topic. |
Examples
async Task<ITopic> GetTopic(Guid topicId)
{
// Retrieve and return a specific topic by an ID in the repository.
var topic = await m_AnnotationRepository.GetTopicAsync(topicId);
return topic;
}
GetTopicsAsync()
Returns the collection of ITopics from the repository.
Declaration
Task<IEnumerable<ITopic>> GetTopicsAsync()
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<ITopic>> | A task whose result is the collection of fetched topics. |
Examples
async Task<IEnumerable<ITopic>> GetTopics()
{
// Retrieve and return all topics in repository.
var topics = await m_AnnotationRepository.GetTopicsAsync();
return topics;
}
UpdateTopicAsync(ITopicUpdate)
Updates an ITopic in the repository.
Declaration
Task<ITopic> UpdateTopicAsync(ITopicUpdate topicUpdate)
Parameters
| Type | Name | Description |
|---|---|---|
| ITopicUpdate | topicUpdate | The ITopicUpdate object that contains the necessary information to update the topic. |
Returns
| Type | Description |
|---|---|
| Task<ITopic> | A task whose result is the updated topic. |
Examples
async Task<ITopic> UpdateTopic(ITopic topicToUpdate, string title, string description)
{
// Creates and populates a TopicUpdate request object.
var topicUpdate = new TopicUpdate(topicToUpdate)
{
// Populate all fields to update.
Title = title,
Description = description
};
// Sends the request to the repository and waits for the updated topic.
var updatedTopic = await m_AnnotationRepository.UpdateTopicAsync(topicUpdate);
return updatedTopic;
}
Events
TopicCreated
Calls the methods in its invocation list when you create an ITopic in the repository.
Declaration
event Action<ITopic> TopicCreated
Event Type
| Type | Description |
|---|---|
| Action<ITopic> |
TopicRemoved
Calls the methods in its invocation list when you remove an ITopic in the repository.
Declaration
event Action<ITopic> TopicRemoved
Event Type
| Type | Description |
|---|---|
| Action<ITopic> |
TopicUpdated
Calls the methods in its invocation list when you update an ITopic in the repository.
Declaration
event Action<ITopic> TopicUpdated
Event Type
| Type | Description |
|---|---|
| Action<ITopic> |