IPoster.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. }
  20. /// <summary>
  21. /// An interface to declare that an <see cref="IPoster{TEntity, TSettings}"/> provides a means to determine if a given <typeparamref name="TEntity"/>
  22. /// needs to be reposted. This function is to be called on the server side when a <typeparamref name="TEntity"/> is saved.
  23. /// </summary>
  24. /// <typeparam name="TEntity"></typeparam>
  25. public interface IAutoRefreshPoster<TEntity, TAutoRefresher>
  26. where TAutoRefresher : IAutoRefresher<TEntity>
  27. {
  28. }
  29. public interface IAutoRefresher<TEntity>
  30. {
  31. /// <summary>
  32. /// Return <see langword="true"/> if <paramref name="entity"/> should be reposted, which will update its <see cref="IPostable.PostedStatus"/> to
  33. /// <see cref="PostedStatus.RequiresRepost"/>.
  34. /// </summary>
  35. /// <param name="entity"></param>
  36. /// <returns></returns>
  37. bool ShouldRepost(TEntity entity);
  38. }
  39. public interface IGlobalSettingsPoster
  40. {
  41. public IGlobalPosterSettings GlobalSettings { get; set; }
  42. }
  43. /// <summary>
  44. /// Declares that an <see cref="IPoster{TEntity, TSettings}"/> has global, entity-independent settings.
  45. /// </summary>
  46. public interface IGlobalSettingsPoster<TGlobalSettings> : IGlobalSettingsPoster
  47. where TGlobalSettings : BaseObject, IGlobalPosterSettings
  48. {
  49. public new TGlobalSettings GlobalSettings { get; set; }
  50. IGlobalPosterSettings IGlobalSettingsPoster.GlobalSettings
  51. {
  52. get => GlobalSettings;
  53. set
  54. {
  55. if(value is TGlobalSettings settings)
  56. {
  57. GlobalSettings = settings;
  58. }
  59. }
  60. }
  61. }
  62. }