ParenthesizePropertyNameAttribute.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // System.ComponentModel.ParenthesizePropertyNameAttribute
  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 ParenthesizePropertyNameAttribute : Attribute
  15. {
  16. private bool parenthesis;
  17. public static readonly ParenthesizePropertyNameAttribute Default = new ParenthesizePropertyNameAttribute();
  18. public ParenthesizePropertyNameAttribute()
  19. {
  20. this.parenthesis = false;
  21. }
  22. public ParenthesizePropertyNameAttribute (bool needParenthesis)
  23. {
  24. this.parenthesis = needParenthesis;
  25. }
  26. public bool NeedParenthesis {
  27. get { return parenthesis; }
  28. }
  29. public override bool Equals (object o)
  30. {
  31. if (!(o is ParenthesizePropertyNameAttribute))
  32. return false;
  33. if (o == this)
  34. return true;
  35. return ((ParenthesizePropertyNameAttribute) o).NeedParenthesis == parenthesis;
  36. }
  37. public override int GetHashCode()
  38. {
  39. return parenthesis.GetHashCode ();
  40. }
  41. public override bool IsDefaultAttribute()
  42. {
  43. return parenthesis == ParenthesizePropertyNameAttribute.Default.NeedParenthesis;
  44. }
  45. }
  46. }