Started work on profiles

This commit is contained in:
Robert committed 2019-11-18 17:33:20 +01:00
1 parent 36f3ec3071
commit bb56a45a7f
28 files changed
+575 -375

No files matched your search

+1
View File
@@ -5,6 +5,7 @@ using Artemis.Core.Exceptions;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage;
using Artemis.Core.Services.Storage.Interfaces;
using RGB.NET.Core;
using Serilog;
using Color = System.Drawing.Color;
@@ -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);
}
}
@@ -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
{
@@ -1,36 +1,46 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage.Interfaces;
using Artemis.Storage.Repositories;
namespace Artemis.Core.Services
namespace Artemis.Core.Services.Storage
{
/// <summary>
/// Provides access to profile storage
/// </summary>
public class StorageService : IStorageService
public class ProfileService : IProfileService
{
private readonly IPluginService _pluginService;
private readonly ProfileRepository _profileRepository;
internal StorageService(IPluginService pluginService)
internal ProfileService(IPluginService pluginService)
{
_pluginService = pluginService;
_profileRepository = new ProfileRepository();
}
public async Task<ICollection<Profile>> GetModuleProfiles(PluginInfo pluginInfo)
public async Task<ICollection<Profile>> GetProfiles(ProfileModule module)
{
var profileEntities = await _profileRepository.GetByPluginGuidAsync(pluginInfo.Guid);
var profileEntities = await _profileRepository.GetByPluginGuidAsync(module.PluginInfo.Guid);
var profiles = new List<Profile>();
foreach (var profileEntity in profileEntities)
profiles.Add(Profile.FromProfileEntity(pluginInfo, profileEntity, _pluginService));
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
@@ -40,9 +50,4 @@ namespace Artemis.Core.Services
await _profileRepository.SaveAsync();
}
}
public interface IStorageService
{
Task<ICollection<Profile>> GetModuleProfiles(PluginInfo pluginInfo);
}
}
@@ -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;