ProvidePropertyAttribute.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // System.ComponentModel.ProvidePropertyAttribute.cs
  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.Class, AllowMultiple = true, Inherited = true)]
  14. public sealed class ProvidePropertyAttribute : Attribute
  15. {
  16. private string Property;
  17. private string Receiver;
  18. public ProvidePropertyAttribute (string propertyName, string receiverTypeName)
  19. {
  20. Property = propertyName;
  21. Receiver = receiverTypeName;
  22. }
  23. public ProvidePropertyAttribute (string propertyName, Type receiverType)
  24. {
  25. Property = propertyName;
  26. Receiver = receiverType.AssemblyQualifiedName;
  27. }
  28. public string PropertyName {
  29. get { return Property; }
  30. }
  31. public string ReceiverTypeName {
  32. get { return Receiver; }
  33. }
  34. public override object TypeId {
  35. get {
  36. // seems to be MS implementation
  37. return base.TypeId + Property;
  38. }
  39. }
  40. public override bool Equals (object obj)
  41. {
  42. if (!(obj is ProvidePropertyAttribute))
  43. return false;
  44. if (obj == this)
  45. return true;
  46. return (((ProvidePropertyAttribute) obj).PropertyName == Property) &&
  47. (((ProvidePropertyAttribute) obj).ReceiverTypeName == Receiver);
  48. }
  49. public override int GetHashCode()
  50. {
  51. return (Property + Receiver).GetHashCode ();
  52. }
  53. }
  54. }