DataRelationPropertyDescriptor.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //------------------------------------------------------------------------------
  2. // <copyright file="DataRelationPropertyDescriptor.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. // <owner current="true" primary="true">[....]</owner>
  6. // <owner current="true" primary="false">[....]</owner>
  7. // <owner current="false" primary="false">[....]</owner>
  8. //------------------------------------------------------------------------------
  9. namespace System.Data {
  10. using System.ComponentModel;
  11. /// <devdoc>
  12. /// <para>[To be supplied.]</para>
  13. /// </devdoc>
  14. internal sealed class DataRelationPropertyDescriptor : PropertyDescriptor {
  15. DataRelation relation;
  16. internal DataRelation Relation {
  17. get {
  18. return relation;
  19. }
  20. }
  21. internal DataRelationPropertyDescriptor(DataRelation dataRelation) : base(dataRelation.RelationName, null) {
  22. this.relation = dataRelation;
  23. }
  24. public override Type ComponentType {
  25. get {
  26. return typeof(DataRowView);
  27. }
  28. }
  29. public override bool IsReadOnly {
  30. get {
  31. return false;
  32. }
  33. }
  34. public override Type PropertyType {
  35. get {
  36. return typeof(IBindingList);
  37. }
  38. }
  39. public override bool Equals(object other) {
  40. if (other is DataRelationPropertyDescriptor) {
  41. DataRelationPropertyDescriptor descriptor = (DataRelationPropertyDescriptor) other;
  42. return(descriptor.Relation == Relation);
  43. }
  44. return false;
  45. }
  46. public override Int32 GetHashCode() {
  47. return Relation.GetHashCode();
  48. }
  49. public override bool CanResetValue(object component) {
  50. return false;
  51. }
  52. public override object GetValue(object component) {
  53. DataRowView dataRowView = (DataRowView) component;
  54. return dataRowView.CreateChildView(relation);
  55. }
  56. public override void ResetValue(object component) {
  57. }
  58. public override void SetValue(object component, object value) {
  59. }
  60. public override bool ShouldSerializeValue(object component) {
  61. return false;
  62. }
  63. }
  64. }