using System; using System.Collections.Generic; using System.Text; namespace InABox.Core { public interface ISettingsImporter { Type SettingsType { get; } void SetSettings(object settings); } public interface ISettingsImporter : ISettingsImporter where TSettings : BaseObject, new() { } public abstract class SettingsImporter : BaseImporter, ISettingsImporter where T : Entity, IRemotable, IPersistent, new() where TSettings : BaseObject, new() { public TSettings Settings { get; set; } = new TSettings(); public Type SettingsType => typeof(TSettings); public void SetSettings(object settings) { if(settings is TSettings tSettings) { Settings = tSettings; } else { throw new Exception($"{settings} is not a {typeof(TSettings)}"); } } } }