mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Started work on profiles
This commit is contained in:
1 parent
36f3ec3071
commit
bb56a45a7f
28 files changed
+575
-375
No files matched your search
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
|
||||
namespace Artemis.Core.Services.Storage.Interfaces
|
||||
{
|
||||
public interface IProfileService : IArtemisService
|
||||
{
|
||||
Task<ICollection<Profile>> GetProfiles(ProfileModule module);
|
||||
Task<Profile> GetActiveProfile(ProfileModule module);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Artemis.Core.Events;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
|
||||
namespace Artemis.Core.Services.Storage
|
||||
namespace Artemis.Core.Services.Storage.Interfaces
|
||||
{
|
||||
public interface ISurfaceService : IArtemisService
|
||||
{
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.Storage.Repositories;
|
||||
|
||||
namespace Artemis.Core.Services.Storage
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to profile storage
|
||||
/// </summary>
|
||||
public class ProfileService : IProfileService
|
||||
{
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly ProfileRepository _profileRepository;
|
||||
|
||||
internal ProfileService(IPluginService pluginService)
|
||||
{
|
||||
_pluginService = pluginService;
|
||||
_profileRepository = new ProfileRepository();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Profile>> GetProfiles(ProfileModule module)
|
||||
{
|
||||
var profileEntities = await _profileRepository.GetByPluginGuidAsync(module.PluginInfo.Guid);
|
||||
var profiles = new List<Profile>();
|
||||
foreach (var profileEntity in profileEntities)
|
||||
profiles.Add(Profile.FromProfileEntity(module.PluginInfo, profileEntity, _pluginService));
|
||||
|
||||
return profiles;
|
||||
}
|
||||
|
||||
public async Task<Profile> GetActiveProfile(ProfileModule module)
|
||||
{
|
||||
var profileEntity = await _profileRepository.GetActiveProfileByPluginGuidAsync(module.PluginInfo.Guid);
|
||||
if (profileEntity == null)
|
||||
return null;
|
||||
|
||||
return Profile.FromProfileEntity(module.PluginInfo, profileEntity, _pluginService);
|
||||
}
|
||||
|
||||
public async Task SaveProfile(Profile profile)
|
||||
{
|
||||
// Find a matching profile entity to update
|
||||
|
||||
// If not found, create a new one
|
||||
|
||||
await _profileRepository.SaveAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using Serilog;
|
||||
|
||||
Reference in new issue
Block a user