IPoster.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace InABox.Core
  5. {
  6. /// <summary>
  7. /// Base interface for all "Posters" - classes that define the means of processing an <see cref="IPostable"/> <see cref="Entity"/>.
  8. /// There is little point in directly implementing this; rather, one should implement a subinterface.
  9. /// The functionality of any <see cref="IPoster{TEntity,TSettings}"/> is essentially the default functionality, and, based on the subinterface implemented,
  10. /// will be scriptable.
  11. /// </summary>
  12. /// <typeparam name="TEntity">The type of entity that this poster can process.</typeparam>
  13. /// <typeparam name="TSettings">The <see cref="PosterSettings"/> specific to this type of poster.</typeparam>
  14. public interface IPoster<TEntity, TSettings>
  15. where TEntity : Entity, IPostable, IRemotable, IPersistent, new()
  16. where TSettings : PosterSettings
  17. {
  18. TSettings Settings { get; set; }
  19. IPosterDispatcher Dispatcher { get; set; }
  20. }
  21. /// <summary>
  22. /// An interface to declare that an <see cref="IPoster{TEntity, TSettings}"/> provides a means to determine if a given <typeparamref name="TEntity"/>
  23. /// needs to be reposted. This function is to be called on the server side when a <typeparamref name="TEntity"/> is saved.
  24. /// </summary>
  25. /// <typeparam name="TEntity"></typeparam>
  26. public interface IAutoRefreshPoster<TEntity, TAutoRefresher>
  27. where TAutoRefresher : IAutoRefresher<TEntity>
  28. {
  29. }
  30. public interface IAutoRefresher<TEntity>
  31. {
  32. /// <summary>
  33. /// Return <see langword="true"/> if <paramref name="entity"/> should be reposted, which will update its <see cref="IPostable.PostedStatus"/> to
  34. /// <see cref="PostedStatus.RequiresRepost"/>.
  35. /// </summary>
  36. /// <param name="entity"></param>
  37. /// <returns></returns>
  38. bool ShouldRepost(TEntity entity);
  39. }
  40. public interface IGlobalSettingsPoster
  41. {
  42. public IGlobalPosterSettings GlobalSettings { get; set; }
  43. }
  44. /// <summary>
  45. /// Declares that an <see cref="IPoster{TEntity, TSettings}"/> has global, entity-independent settings.
  46. /// </summary>
  47. public interface IGlobalSettingsPoster<TGlobalSettings> : IGlobalSettingsPoster
  48. where TGlobalSettings : BaseObject, IGlobalPosterSettings
  49. {
  50. public new TGlobalSettings GlobalSettings { get; set; }
  51. IGlobalPosterSettings IGlobalSettingsPoster.GlobalSettings
  52. {
  53. get => GlobalSettings;
  54. set
  55. {
  56. if(value is TGlobalSettings settings)
  57. {
  58. GlobalSettings = settings;
  59. }
  60. }
  61. }
  62. }
  63. }