IPostable.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace InABox.Core
  5. {
  6. public enum PostedStatus
  7. {
  8. NeverPosted,
  9. PostFailed,
  10. RequiresRepost,
  11. Posted
  12. }
  13. /// <summary>
  14. /// Flags an <see cref="Entity"/> as "Postable"; that is, it can be processed by an <see cref="IPoster{TEntity,TSettings}"/>.
  15. /// </summary>
  16. public interface IPostable : IPostableFragment
  17. {
  18. /// <summary>
  19. /// At what time this <see cref="IPostable"/> was processed. Set to <see cref="DateTime.MinValue"/> if not processed yet.
  20. /// When the <see cref="IPostable"/> is processed, this should be updated, so that we don't process things twice.
  21. /// </summary>
  22. DateTime Posted { get; set; }
  23. PostedStatus PostedStatus { get; set; }
  24. string PostedNote { get; set; }
  25. public void Post()
  26. {
  27. Posted = DateTime.Now;
  28. PostedStatus = PostedStatus.Posted;
  29. PostedNote = "";
  30. }
  31. public void FailPost(string note)
  32. {
  33. Posted = DateTime.Now;
  34. PostedStatus = PostedStatus.PostFailed;
  35. PostedNote = note;
  36. }
  37. }
  38. }