mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Surface - Removed the ArtemisSurface and reworked device loading
This commit is contained in:
1 parent
7ccc9c54fb
commit
056b2bface
50 files changed
+1292
-1506
No files matched your search
@@ -8,8 +8,8 @@ namespace Artemis.Storage.Entities.Surface
|
||||
{
|
||||
InputIdentifiers = new List<DeviceInputIdentifierEntity>();
|
||||
}
|
||||
|
||||
public string DeviceIdentifier { get; set; }
|
||||
|
||||
public string Id { get; set; }
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public double Rotation { get; set; }
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.Surface
|
||||
{
|
||||
public class SurfaceEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
public List<DeviceEntity> DeviceEntities { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Surface;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
{
|
||||
internal class DeviceRepository : IDeviceRepository
|
||||
{
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
public DeviceRepository(LiteRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<DeviceEntity>().EnsureIndex(s => s.Id);
|
||||
}
|
||||
|
||||
public void Add(DeviceEntity deviceEntity)
|
||||
{
|
||||
_repository.Insert(deviceEntity);
|
||||
}
|
||||
|
||||
public void Remove(DeviceEntity deviceEntity)
|
||||
{
|
||||
_repository.Delete<DeviceEntity>(deviceEntity.Id);
|
||||
}
|
||||
|
||||
public DeviceEntity Get(string id)
|
||||
{
|
||||
return _repository.FirstOrDefault<DeviceEntity>(s => s.Id == id);
|
||||
}
|
||||
|
||||
public List<DeviceEntity> GetAll()
|
||||
{
|
||||
return _repository.Query<DeviceEntity>().Include(s => s.InputIdentifiers).ToList();
|
||||
}
|
||||
|
||||
public void Save(DeviceEntity deviceEntity)
|
||||
{
|
||||
_repository.Upsert(deviceEntity);
|
||||
}
|
||||
|
||||
public void Save(IEnumerable<DeviceEntity> deviceEntities)
|
||||
{
|
||||
_repository.Upsert(deviceEntities);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Surface;
|
||||
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
{
|
||||
public interface IDeviceRepository : IRepository
|
||||
{
|
||||
void Add(DeviceEntity deviceEntity);
|
||||
void Remove(DeviceEntity deviceEntity);
|
||||
DeviceEntity Get(string id);
|
||||
List<DeviceEntity> GetAll();
|
||||
void Save(DeviceEntity deviceEntity);
|
||||
void Save(IEnumerable<DeviceEntity> deviceEntities);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.Surface;
|
||||
|
||||
namespace Artemis.Storage.Repositories.Interfaces
|
||||
{
|
||||
public interface ISurfaceRepository : IRepository
|
||||
{
|
||||
void Add(SurfaceEntity surfaceEntity);
|
||||
void Remove(SurfaceEntity surfaceEntity);
|
||||
SurfaceEntity GetByName(string name);
|
||||
List<SurfaceEntity> GetAll();
|
||||
|
||||
void Save(SurfaceEntity surfaceEntity);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Storage.Entities.Surface;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
{
|
||||
internal class SurfaceRepository : ISurfaceRepository
|
||||
{
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
public SurfaceRepository(LiteRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<SurfaceEntity>().EnsureIndex(s => s.Name);
|
||||
}
|
||||
|
||||
public void Add(SurfaceEntity surfaceEntity)
|
||||
{
|
||||
_repository.Insert(surfaceEntity);
|
||||
}
|
||||
|
||||
public void Remove(SurfaceEntity surfaceEntity)
|
||||
{
|
||||
_repository.Delete<SurfaceEntity>(surfaceEntity.Id);
|
||||
}
|
||||
|
||||
public SurfaceEntity GetByName(string name)
|
||||
{
|
||||
return _repository.FirstOrDefault<SurfaceEntity>(s => s.Name == name);
|
||||
}
|
||||
|
||||
public List<SurfaceEntity> GetAll()
|
||||
{
|
||||
return _repository.Query<SurfaceEntity>().Include(s => s.DeviceEntities.Select(de => de.InputIdentifiers)).ToList();
|
||||
}
|
||||
|
||||
public void Save(SurfaceEntity surfaceEntity)
|
||||
{
|
||||
_repository.Upsert(surfaceEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user