IMethodResponse.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* This file is part of OpenSubtitles Handler
  2. A library that handle OpenSubtitles.org XML-RPC methods.
  3. Copyright © Ala Ibrahim Hadid 2013
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. using System;
  16. using System.ComponentModel;
  17. namespace OpenSubtitlesHandler
  18. {
  19. /// <summary>
  20. /// When you call a method to communicate with OpenSubtitles server, that method should return this response with the reuired information.
  21. /// </summary>
  22. public abstract class IMethodResponse
  23. {
  24. public IMethodResponse() { LoadAttributes(); }
  25. public IMethodResponse(string name, string message)
  26. {
  27. this.name = name;
  28. this.message = message;
  29. }
  30. protected string name;
  31. protected string message;
  32. protected double seconds;
  33. protected string status;
  34. protected void LoadAttributes()
  35. {
  36. //foreach (Attribute attr in Attribute.GetCustomAttributes(this.GetType()))
  37. //{
  38. // if (attr.GetType() == typeof(MethodResponseDescription))
  39. // {
  40. // this.name = ((MethodResponseDescription)attr).Name;
  41. // this.message = ((MethodResponseDescription)attr).Message;
  42. // break;
  43. // }
  44. //}
  45. }
  46. [Description("The name of this response"), Category("MethodResponse")]
  47. public virtual string Name { get { return name; } set { name = value; } }
  48. [Description("The message about this response"), Category("MethodResponse")]
  49. public virtual string Message { get { return message; } set { message = value; } }
  50. [Description("Time taken to execute this command on server"), Category("MethodResponse")]
  51. public double Seconds { get { return seconds; } set { seconds = value; } }
  52. [Description("The status"), Category("MethodResponse")]
  53. public string Status { get { return status; } set { status = value; } }
  54. }
  55. public class DescriptionAttribute : Attribute
  56. {
  57. public DescriptionAttribute(string text) { }
  58. }
  59. public class CategoryAttribute : Attribute
  60. {
  61. public CategoryAttribute(string text) { }
  62. }
  63. }