LispAttributes.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 string AlternativeName;
  47. public LispChildAttribute(string Name) {
  48. this.Name = Name;
  49. }
  50. }
  51. // *NOTE*: This is guesswork, please confirm that it is correct.
  52. // Marks a field or property as being a list(?) that can contain
  53. // classes marked with LispRootAttribute? (See Level.Sectors and
  54. // Sector for example.)
  55. [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property,
  56. AllowMultiple=true)]
  57. public sealed class LispChildsAttribute : Attribute
  58. {
  59. public string Name;
  60. public Type Type;
  61. private Type _listType;
  62. public Type ListType {
  63. set {
  64. _listType = value;
  65. }
  66. get {
  67. if(_listType == null)
  68. return Type;
  69. else
  70. return _listType;
  71. }
  72. }
  73. }
  74. }