Code style - Use file scoped namespaces

Code style - Ran code cleanup
This commit is contained in:
Robert committed 2022-08-21 11:36:15 +02:00
1 parent e68e16df4d
commit f6090dc296
691 files changed
+37301 -38119

No files matched your search

@@ -3,46 +3,45 @@ using Artemis.Storage.Entities.Surface;
using Artemis.Storage.Repositories.Interfaces;
using LiteDB;
namespace Artemis.Storage.Repositories
namespace Artemis.Storage.Repositories;
internal class DeviceRepository : IDeviceRepository
{
internal class DeviceRepository : IDeviceRepository
private readonly LiteRepository _repository;
public DeviceRepository(LiteRepository repository)
{
private readonly LiteRepository _repository;
_repository = repository;
_repository.Database.GetCollection<DeviceEntity>().EnsureIndex(s => s.Id);
}
public DeviceRepository(LiteRepository repository)
{
_repository = repository;
_repository.Database.GetCollection<DeviceEntity>().EnsureIndex(s => s.Id);
}
public void Add(DeviceEntity deviceEntity)
{
_repository.Insert(deviceEntity);
}
public void Add(DeviceEntity deviceEntity)
{
_repository.Insert(deviceEntity);
}
public void Remove(DeviceEntity deviceEntity)
{
_repository.Delete<DeviceEntity>(deviceEntity.Id);
}
public void Remove(DeviceEntity deviceEntity)
{
_repository.Delete<DeviceEntity>(deviceEntity.Id);
}
public DeviceEntity Get(string id)
{
return _repository.FirstOrDefault<DeviceEntity>(s => s.Id == 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 List<DeviceEntity> GetAll()
{
return _repository.Query<DeviceEntity>().Include(s => s.InputIdentifiers).ToList();
}
public void Save(DeviceEntity deviceEntity)
{
_repository.Upsert(deviceEntity);
}
public void Save(DeviceEntity deviceEntity)
{
_repository.Upsert(deviceEntity);
}
public void Save(IEnumerable<DeviceEntity> deviceEntities)
{
_repository.Upsert(deviceEntities);
}
public void Save(IEnumerable<DeviceEntity> deviceEntities)
{
_repository.Upsert(deviceEntities);
}
}
@@ -1,15 +1,14 @@
using System.Collections.Generic;
using Artemis.Storage.Entities.Surface;
namespace Artemis.Storage.Repositories.Interfaces
namespace Artemis.Storage.Repositories.Interfaces;
public interface IDeviceRepository : IRepository
{
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);
}
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,18 +1,17 @@
using System;
using Artemis.Storage.Entities.Plugins;
namespace Artemis.Storage.Repositories.Interfaces
{
public interface IPluginRepository : IRepository
{
void AddPlugin(PluginEntity pluginEntity);
PluginEntity GetPluginByGuid(Guid pluginGuid);
void SavePlugin(PluginEntity pluginEntity);
namespace Artemis.Storage.Repositories.Interfaces;
void AddSetting(PluginSettingEntity pluginSettingEntity);
PluginSettingEntity GetSettingByGuid(Guid pluginGuid);
PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid);
void SaveSetting(PluginSettingEntity pluginSettingEntity);
void RemoveSettings(Guid pluginGuid);
}
public interface IPluginRepository : IRepository
{
void AddPlugin(PluginEntity pluginEntity);
PluginEntity GetPluginByGuid(Guid pluginGuid);
void SavePlugin(PluginEntity pluginEntity);
void AddSetting(PluginSettingEntity pluginSettingEntity);
PluginSettingEntity GetSettingByGuid(Guid pluginGuid);
PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid);
void SaveSetting(PluginSettingEntity pluginSettingEntity);
void RemoveSettings(Guid pluginGuid);
}
@@ -3,17 +3,16 @@ using System.Collections.Generic;
using System.IO;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Storage.Repositories.Interfaces
namespace Artemis.Storage.Repositories.Interfaces;
public interface IProfileCategoryRepository : IRepository
{
public interface IProfileCategoryRepository : IRepository
{
void Add(ProfileCategoryEntity profileCategoryEntity);
void Remove(ProfileCategoryEntity profileCategoryEntity);
List<ProfileCategoryEntity> GetAll();
ProfileCategoryEntity Get(Guid id);
Stream GetProfileIconStream(Guid id);
void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream);
ProfileCategoryEntity IsUnique(string name, Guid? id);
void Save(ProfileCategoryEntity profileCategoryEntity);
}
void Add(ProfileCategoryEntity profileCategoryEntity);
void Remove(ProfileCategoryEntity profileCategoryEntity);
List<ProfileCategoryEntity> GetAll();
ProfileCategoryEntity Get(Guid id);
Stream GetProfileIconStream(Guid id);
void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream);
ProfileCategoryEntity IsUnique(string name, Guid? id);
void Save(ProfileCategoryEntity profileCategoryEntity);
}
@@ -2,14 +2,13 @@
using System.Collections.Generic;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Storage.Repositories.Interfaces
namespace Artemis.Storage.Repositories.Interfaces;
public interface IProfileRepository : IRepository
{
public interface IProfileRepository : IRepository
{
void Add(ProfileEntity profileEntity);
void Remove(ProfileEntity profileEntity);
List<ProfileEntity> GetAll();
ProfileEntity Get(Guid id);
void Save(ProfileEntity profileEntity);
}
void Add(ProfileEntity profileEntity);
void Remove(ProfileEntity profileEntity);
List<ProfileEntity> GetAll();
ProfileEntity Get(Guid id);
void Save(ProfileEntity profileEntity);
}
@@ -1,13 +1,12 @@
using System.Collections.Generic;
using Artemis.Storage.Entities.General;
namespace Artemis.Storage.Repositories.Interfaces
namespace Artemis.Storage.Repositories.Interfaces;
public interface IQueuedActionRepository : IRepository
{
public interface IQueuedActionRepository : IRepository
{
void Add(QueuedActionEntity queuedActionEntity);
void Remove(QueuedActionEntity queuedActionEntity);
List<QueuedActionEntity> GetAll();
List<QueuedActionEntity> GetByType(string type);
}
void Add(QueuedActionEntity queuedActionEntity);
void Remove(QueuedActionEntity queuedActionEntity);
List<QueuedActionEntity> GetAll();
List<QueuedActionEntity> GetByType(string type);
}
@@ -1,6 +1,5 @@
namespace Artemis.Storage.Repositories.Interfaces
namespace Artemis.Storage.Repositories.Interfaces;
public interface IRepository
{
public interface IRepository
{
}
}
@@ -1,62 +1,60 @@
using System;
using System.Collections.Generic;
using Artemis.Storage.Entities.Plugins;
using Artemis.Storage.Repositories.Interfaces;
using LiteDB;
namespace Artemis.Storage.Repositories
namespace Artemis.Storage.Repositories;
internal class PluginRepository : IPluginRepository
{
internal class PluginRepository : IPluginRepository
private readonly LiteRepository _repository;
public PluginRepository(LiteRepository repository)
{
private readonly LiteRepository _repository;
_repository = repository;
public PluginRepository(LiteRepository repository)
{
_repository = repository;
_repository.Database.GetCollection<PluginSettingEntity>().EnsureIndex(s => new {s.Name, s.PluginGuid}, true);
}
_repository.Database.GetCollection<PluginSettingEntity>().EnsureIndex(s => new {s.Name, s.PluginGuid}, true);
}
public void AddPlugin(PluginEntity pluginEntity)
{
_repository.Insert(pluginEntity);
}
public void AddPlugin(PluginEntity pluginEntity)
{
_repository.Insert(pluginEntity);
}
public PluginEntity GetPluginByGuid(Guid pluginGuid)
{
return _repository.FirstOrDefault<PluginEntity>(p => p.Id == pluginGuid);
}
public PluginEntity GetPluginByGuid(Guid pluginGuid)
{
return _repository.FirstOrDefault<PluginEntity>(p => p.Id == pluginGuid);
}
public void SavePlugin(PluginEntity pluginEntity)
{
_repository.Upsert(pluginEntity);
_repository.Database.Checkpoint();
}
public void SavePlugin(PluginEntity pluginEntity)
{
_repository.Upsert(pluginEntity);
_repository.Database.Checkpoint();
}
public void AddSetting(PluginSettingEntity pluginSettingEntity)
{
_repository.Insert(pluginSettingEntity);
}
public void AddSetting(PluginSettingEntity pluginSettingEntity)
{
_repository.Insert(pluginSettingEntity);
}
public PluginSettingEntity GetSettingByGuid(Guid pluginGuid)
{
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.PluginGuid == pluginGuid);
}
public PluginSettingEntity GetSettingByGuid(Guid pluginGuid)
{
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.PluginGuid == pluginGuid);
}
public PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid)
{
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.Name == name && p.PluginGuid == pluginGuid);
}
public PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid)
{
return _repository.FirstOrDefault<PluginSettingEntity>(p => p.Name == name && p.PluginGuid == pluginGuid);
}
public void SaveSetting(PluginSettingEntity pluginSettingEntity)
{
_repository.Upsert(pluginSettingEntity);
}
public void SaveSetting(PluginSettingEntity pluginSettingEntity)
{
_repository.Upsert(pluginSettingEntity);
}
/// <inheritdoc />
public void RemoveSettings(Guid pluginGuid)
{
_repository.DeleteMany<PluginSettingEntity>(s => s.PluginGuid == pluginGuid);
}
/// <inheritdoc />
public void RemoveSettings(Guid pluginGuid)
{
_repository.DeleteMany<PluginSettingEntity>(s => s.PluginGuid == pluginGuid);
}
}
@@ -5,72 +5,71 @@ using Artemis.Storage.Entities.Profile;
using Artemis.Storage.Repositories.Interfaces;
using LiteDB;
namespace Artemis.Storage.Repositories
namespace Artemis.Storage.Repositories;
internal class ProfileCategoryRepository : IProfileCategoryRepository
{
internal class ProfileCategoryRepository : IProfileCategoryRepository
private readonly ILiteStorage<Guid> _profileIcons;
private readonly LiteRepository _repository;
public ProfileCategoryRepository(LiteRepository repository)
{
private readonly LiteRepository _repository;
private readonly ILiteStorage<Guid> _profileIcons;
_repository = repository;
_repository.Database.GetCollection<ProfileCategoryEntity>().EnsureIndex(s => s.Name, true);
_profileIcons = _repository.Database.GetStorage<Guid>("profileIcons");
}
public ProfileCategoryRepository(LiteRepository repository)
{
_repository = repository;
_repository.Database.GetCollection<ProfileCategoryEntity>().EnsureIndex(s => s.Name, true);
_profileIcons = _repository.Database.GetStorage<Guid>("profileIcons");
}
public void Add(ProfileCategoryEntity profileCategoryEntity)
{
_repository.Insert(profileCategoryEntity);
}
public void Add(ProfileCategoryEntity profileCategoryEntity)
{
_repository.Insert(profileCategoryEntity);
}
public void Remove(ProfileCategoryEntity profileCategoryEntity)
{
_repository.Delete<ProfileCategoryEntity>(profileCategoryEntity.Id);
}
public void Remove(ProfileCategoryEntity profileCategoryEntity)
{
_repository.Delete<ProfileCategoryEntity>(profileCategoryEntity.Id);
}
public List<ProfileCategoryEntity> GetAll()
{
return _repository.Query<ProfileCategoryEntity>().ToList();
}
public List<ProfileCategoryEntity> GetAll()
{
return _repository.Query<ProfileCategoryEntity>().ToList();
}
public ProfileCategoryEntity Get(Guid id)
{
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Id == id);
}
public ProfileCategoryEntity Get(Guid id)
{
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Id == id);
}
public ProfileCategoryEntity IsUnique(string name, Guid? id)
{
name = name.Trim();
if (id == null)
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Name == name);
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Name == name && p.Id != id.Value);
}
public ProfileCategoryEntity IsUnique(string name, Guid? id)
{
name = name.Trim();
if (id == null)
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Name == name);
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Name == name && p.Id != id.Value);
}
public void Save(ProfileCategoryEntity profileCategoryEntity)
{
_repository.Upsert(profileCategoryEntity);
}
public void Save(ProfileCategoryEntity profileCategoryEntity)
{
_repository.Upsert(profileCategoryEntity);
}
public Stream GetProfileIconStream(Guid id)
{
if (!_profileIcons.Exists(id))
return null;
public Stream GetProfileIconStream(Guid id)
{
if (!_profileIcons.Exists(id))
return null;
MemoryStream stream = new();
_profileIcons.Download(id, stream);
return stream;
}
MemoryStream stream = new();
_profileIcons.Download(id, stream);
return stream;
}
public void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream)
{
if (profileConfigurationEntity.FileIconId == Guid.Empty)
profileConfigurationEntity.FileIconId = Guid.NewGuid();
public void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream)
{
if (profileConfigurationEntity.FileIconId == Guid.Empty)
profileConfigurationEntity.FileIconId = Guid.NewGuid();
if (stream == null && _profileIcons.Exists(profileConfigurationEntity.FileIconId))
_profileIcons.Delete(profileConfigurationEntity.FileIconId);
if (stream == null && _profileIcons.Exists(profileConfigurationEntity.FileIconId))
_profileIcons.Delete(profileConfigurationEntity.FileIconId);
_profileIcons.Upload(profileConfigurationEntity.FileIconId, profileConfigurationEntity.IconOriginalFileName, stream);
}
_profileIcons.Upload(profileConfigurationEntity.FileIconId, profileConfigurationEntity.IconOriginalFileName, stream);
}
}
@@ -4,41 +4,40 @@ using Artemis.Storage.Entities.Profile;
using Artemis.Storage.Repositories.Interfaces;
using LiteDB;
namespace Artemis.Storage.Repositories
namespace Artemis.Storage.Repositories;
internal class ProfileRepository : IProfileRepository
{
internal class ProfileRepository : IProfileRepository
private readonly LiteRepository _repository;
public ProfileRepository(LiteRepository repository)
{
private readonly LiteRepository _repository;
_repository = repository;
_repository.Database.GetCollection<ProfileEntity>().EnsureIndex(s => s.Name);
}
public ProfileRepository(LiteRepository repository)
{
_repository = repository;
_repository.Database.GetCollection<ProfileEntity>().EnsureIndex(s => s.Name);
}
public void Add(ProfileEntity profileEntity)
{
_repository.Insert(profileEntity);
}
public void Add(ProfileEntity profileEntity)
{
_repository.Insert(profileEntity);
}
public void Remove(ProfileEntity profileEntity)
{
_repository.Delete<ProfileEntity>(profileEntity.Id);
}
public void Remove(ProfileEntity profileEntity)
{
_repository.Delete<ProfileEntity>(profileEntity.Id);
}
public List<ProfileEntity> GetAll()
{
return _repository.Query<ProfileEntity>().ToList();
}
public List<ProfileEntity> GetAll()
{
return _repository.Query<ProfileEntity>().ToList();
}
public ProfileEntity Get(Guid id)
{
return _repository.FirstOrDefault<ProfileEntity>(p => p.Id == id);
}
public ProfileEntity Get(Guid id)
{
return _repository.FirstOrDefault<ProfileEntity>(p => p.Id == id);
}
public void Save(ProfileEntity profileEntity)
{
_repository.Upsert(profileEntity);
}
public void Save(ProfileEntity profileEntity)
{
_repository.Upsert(profileEntity);
}
}
@@ -3,44 +3,43 @@ using Artemis.Storage.Entities.General;
using Artemis.Storage.Repositories.Interfaces;
using LiteDB;
namespace Artemis.Storage.Repositories
namespace Artemis.Storage.Repositories;
public class QueuedActionRepository : IQueuedActionRepository
{
public class QueuedActionRepository : IQueuedActionRepository
private readonly LiteRepository _repository;
public QueuedActionRepository(LiteRepository repository)
{
private readonly LiteRepository _repository;
public QueuedActionRepository(LiteRepository repository)
{
_repository = repository;
_repository.Database.GetCollection<QueuedActionEntity>().EnsureIndex(s => s.Type);
}
#region Implementation of IQueuedActionRepository
/// <inheritdoc />
public void Add(QueuedActionEntity queuedActionEntity)
{
_repository.Insert(queuedActionEntity);
}
/// <inheritdoc />
public void Remove(QueuedActionEntity queuedActionEntity)
{
_repository.Delete<QueuedActionEntity>(queuedActionEntity.Id);
}
/// <inheritdoc />
public List<QueuedActionEntity> GetAll()
{
return _repository.Query<QueuedActionEntity>().ToList();
}
/// <inheritdoc />
public List<QueuedActionEntity> GetByType(string type)
{
return _repository.Query<QueuedActionEntity>().Where(q => q.Type == type).ToList();
}
#endregion
_repository = repository;
_repository.Database.GetCollection<QueuedActionEntity>().EnsureIndex(s => s.Type);
}
#region Implementation of IQueuedActionRepository
/// <inheritdoc />
public void Add(QueuedActionEntity queuedActionEntity)
{
_repository.Insert(queuedActionEntity);
}
/// <inheritdoc />
public void Remove(QueuedActionEntity queuedActionEntity)
{
_repository.Delete<QueuedActionEntity>(queuedActionEntity.Id);
}
/// <inheritdoc />
public List<QueuedActionEntity> GetAll()
{
return _repository.Query<QueuedActionEntity>().ToList();
}
/// <inheritdoc />
public List<QueuedActionEntity> GetByType(string type)
{
return _repository.Query<QueuedActionEntity>().Where(q => q.Type == type).ToList();
}
#endregion
}