BindingMemberInfo.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Permission is hereby granted, free of charge, to any person obtaining
  2. // a copy of this software and associated documentation files (the
  3. // "Software"), to deal in the Software without restriction, including
  4. // without limitation the rights to use, copy, modify, merge, publish,
  5. // distribute, sublicense, and/or sell copies of the Software, and to
  6. // permit persons to whom the Software is furnished to do so, subject to
  7. // the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be
  10. // included in all copies or substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  16. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  17. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. //
  20. // Copyright (c) 2004 Novell, Inc.
  21. //
  22. // Authors:
  23. // Peter Bartok [email protected]
  24. //
  25. //
  26. // $Revision: 1.2 $
  27. // $Modtime: $
  28. // $Log: BindingMemberInfo.cs,v $
  29. // Revision 1.2 2004/08/11 22:20:59 pbartok
  30. // - Signature fixes
  31. //
  32. // Revision 1.1 2004/07/09 05:21:25 pbartok
  33. // - Initial check-in
  34. //
  35. //
  36. // COMPLETE
  37. namespace System.Windows.Forms {
  38. public struct BindingMemberInfo {
  39. private string data_member;
  40. private string data_field;
  41. private string data_path;
  42. #region Public Constructors
  43. public BindingMemberInfo(string dataMember) {
  44. int i;
  45. if (dataMember!=null) {
  46. this.data_member=dataMember;
  47. } else {
  48. this.data_member=String.Empty;
  49. }
  50. // Break out our components
  51. i=data_member.LastIndexOf('.');
  52. if (i!=-1) {
  53. data_field=data_member.Substring(i+1);
  54. data_path=data_member.Substring(0, i);
  55. } else {
  56. data_field=data_member;
  57. data_path=String.Empty;
  58. }
  59. }
  60. #endregion // Public Constructors
  61. #region Public Instance Properties
  62. public string BindingField {
  63. get {
  64. return this.data_field;
  65. }
  66. }
  67. public string BindingMember {
  68. get {
  69. return this.data_member;
  70. }
  71. }
  72. public string BindingPath {
  73. get {
  74. return this.data_path;
  75. }
  76. }
  77. #endregion // Public Instance Properties
  78. #region Public Instance Methods
  79. public override bool Equals(object otherObject) {
  80. if (otherObject is BindingMemberInfo) {
  81. return ((this.data_field == ((BindingMemberInfo)otherObject).data_field) &&
  82. (this.data_path == ((BindingMemberInfo)otherObject).data_path) &&
  83. (this.data_member == ((BindingMemberInfo)otherObject).data_member));
  84. } else {
  85. return false;
  86. }
  87. }
  88. public override int GetHashCode() {
  89. return this.data_member.GetHashCode();
  90. }
  91. #endregion // Public Instance Methods
  92. }
  93. }