LispAttributes.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // $Id$
  2. using System;
  3. namespace LispReader
  4. {
  5. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct,
  6. AllowMultiple=false)]
  7. public sealed class LispRootAttribute : Attribute
  8. {
  9. public string Name;
  10. public LispRootAttribute(string name)
  11. {
  12. this.Name = name;
  13. }
  14. }
  15. /// <summary>
  16. /// Marks a class or struct as a serializer
  17. /// for <see cref="LispCustomSerializerAttribute.Type"/>
  18. /// </summary>
  19. /// <remarks>
  20. /// The class marked with this must implement
  21. /// <see cref="Lisp.ILispSerializer"/>.
  22. /// </remarks>
  23. /// <seealso cref="Lisp.ILispSerializer"/>
  24. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct,
  25. AllowMultiple=false)]
  26. public sealed class LispCustomSerializerAttribute : Attribute
  27. {
  28. public Type Type;
  29. public LispCustomSerializerAttribute(Type type)
  30. {
  31. this.Type = type;
  32. }
  33. }
  34. /// <summary>
  35. /// Maps a field or property in a class to a lisp construct.
  36. /// </summary>
  37. [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property,
  38. AllowMultiple=false)]
  39. public sealed class LispChildAttribute : Attribute
  40. {
  41. public bool Translatable;
  42. public bool Optional;
  43. public bool Transient;
  44. public object Default;
  45. public string Name;
  46. public LispChildAttribute(string Name) {
  47. this.Name = Name;
  48. }
  49. }
  50. // *NOTE*: This is guesswork, please confirm that it is correct.
  51. // Marks a field or property as being a list(?) that can contain
  52. // classes marked with LispRootAttribute? (See Level.Sectors and
  53. // Sector for example.)
  54. [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property,
  55. AllowMultiple=true)]
  56. public sealed class LispChildsAttribute : Attribute
  57. {
  58. public string Name;
  59. public Type Type;
  60. private Type _listType;
  61. public Type ListType {
  62. set {
  63. _listType = value;
  64. }
  65. get {
  66. if(_listType == null)
  67. return Type;
  68. else
  69. return _listType;
  70. }
  71. }
  72. }
  73. }