123456789101112131415161718192021222324252627282930313233343536373839 |
- 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<TSettings> : ISettingsImporter
- where TSettings : BaseObject, new()
- {
- }
- public abstract class SettingsImporter<T, TSettings> : BaseImporter<T>, ISettingsImporter<TSettings>
- 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)}");
- }
- }
- }
- }
|