XPathNodeViewPropertyDescriptor.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //------------------------------------------------------------------------------
  2. // <copyright file="XPathNodeViewPropertyDescriptor.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. // <owner current="true" primary="true">derekdb</owner>
  6. //------------------------------------------------------------------------------
  7. #if ENABLEDATABINDING
  8. using System;
  9. using System.Xml;
  10. using System.Xml.XPath;
  11. using System.Xml.Schema;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.ComponentModel;
  15. using System.Diagnostics;
  16. namespace System.Xml.XPath.DataBinding
  17. {
  18. internal class XPathNodeViewPropertyDescriptor : PropertyDescriptor {
  19. Shape rowShape;
  20. Shape colShape;
  21. int colIndex;
  22. internal XPathNodeViewPropertyDescriptor(Shape rowShape)
  23. : base( rowShape.Name, null) {
  24. this.rowShape = rowShape;
  25. this.colShape = rowShape;
  26. this.colIndex = 0;
  27. }
  28. internal XPathNodeViewPropertyDescriptor(Shape rowShape, Shape colShape, int colIndex)
  29. : base( colShape.Name, null) {
  30. this.rowShape = rowShape;
  31. this.colShape = colShape;
  32. this.colIndex = colIndex;
  33. }
  34. public Shape Shape {
  35. get { return colShape; }
  36. }
  37. public override Type ComponentType {
  38. get { return null; }
  39. }
  40. public override string Name {
  41. get { return this.colShape.Name; }
  42. }
  43. public override bool IsReadOnly {
  44. get { return true; }
  45. }
  46. public override Type PropertyType {
  47. get {
  48. return this.colShape.IsNestedTable
  49. ? typeof(XPathDocumentView)
  50. : typeof(string);
  51. }
  52. }
  53. public override bool CanResetValue(object o) {
  54. return false;
  55. }
  56. public override object GetValue(object o) {
  57. if (null == o)
  58. throw new ArgumentNullException("XPathNodeViewPropertyDescriptor.GetValue");
  59. XPathNodeView xiv = (XPathNodeView)o;
  60. if (xiv.Collection.RowShape != this.rowShape)
  61. throw new ArgumentException("XPathNodeViewPropertyDescriptor.GetValue");
  62. object val = xiv.Column(this.colIndex);
  63. XPathNode nd = val as XPathNode;
  64. if (null != nd) {
  65. XPathDocumentNavigator nav = new XPathDocumentNavigator(nd, null);
  66. XmlSchemaType xst = nd.SchemaType;
  67. XmlSchemaComplexType xsct = xst as XmlSchemaComplexType;
  68. if (null == xst || ( (null != xsct) && xsct.IsMixed) ) {
  69. return nav.InnerXml;
  70. }
  71. else {
  72. return nav.TypedValue;
  73. }
  74. }
  75. return val;
  76. }
  77. public override void ResetValue(object o) {
  78. throw new NotImplementedException();
  79. }
  80. public override void SetValue(object o, object value) {
  81. throw new NotImplementedException();
  82. }
  83. public override bool ShouldSerializeValue(object o) {
  84. return false;
  85. }
  86. }
  87. }
  88. #endif