ImmutableObjectAttribute.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // System.ComponentModel.ImmutableObjectAttribute
  3. //
  4. // Authors:
  5. // Martin Willemoes Hansen ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) 2003 Martin Willemoes Hansen
  9. // (C) 2003 Andreas Nahr
  10. //
  11. namespace System.ComponentModel
  12. {
  13. [AttributeUsage(AttributeTargets.All)]
  14. public sealed class ImmutableObjectAttribute : Attribute
  15. {
  16. private bool immutable;
  17. public static readonly ImmutableObjectAttribute Default = new ImmutableObjectAttribute (false);
  18. public static readonly ImmutableObjectAttribute No = new ImmutableObjectAttribute (false);
  19. public static readonly ImmutableObjectAttribute Yes = new ImmutableObjectAttribute (true);
  20. public ImmutableObjectAttribute (bool immutable)
  21. {
  22. this.immutable=immutable;
  23. }
  24. public bool Immutable {
  25. get { return this.immutable; }
  26. }
  27. public override bool Equals (object obj)
  28. {
  29. if (!(obj is ImmutableObjectAttribute))
  30. return false;
  31. if (obj == this)
  32. return true;
  33. return ((ImmutableObjectAttribute) obj).Immutable == immutable;
  34. }
  35. public override int GetHashCode()
  36. {
  37. return immutable.GetHashCode ();
  38. }
  39. public override bool IsDefaultAttribute()
  40. {
  41. return immutable == ImmutableObjectAttribute.Default.Immutable;
  42. }
  43. }
  44. }