The Labs \ Source Viewer \ SSCLI \ System.Xml.XPath.DataBinding \ XPathNodeViewPropertyDescriptor

  1. //------------------------------------------------------------------------------
  2. // <copyright file="XPathNodeViewPropertyDescriptor.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. #if ENABLEDATABINDING
  16. using System;
  17. using System.Xml;
  18. using System.Xml.XPath;
  19. using System.Xml.Schema;
  20. using System.Collections;
  21. using System.Collections.Generic;
  22. using System.ComponentModel;
  23. using System.Diagnostics;
  24. namespace System.Xml.XPath.DataBinding
  25. {
  26.     internal class XPathNodeViewPropertyDescriptor : PropertyDescriptor
  27.     {
  28.         Shape rowShape;
  29.         Shape colShape;
  30.         int colIndex;
  31.        
  32.         internal XPathNodeViewPropertyDescriptor(Shape rowShape) : base(rowShape.Name, null)
  33.         {
  34.             this.rowShape = rowShape;
  35.             this.colShape = rowShape;
  36.             this.colIndex = 0;
  37.         }
  38.        
  39.         internal XPathNodeViewPropertyDescriptor(Shape rowShape, Shape colShape, int colIndex) : base(colShape.Name, null)
  40.         {
  41.             this.rowShape = rowShape;
  42.             this.colShape = colShape;
  43.             this.colIndex = colIndex;
  44.         }
  45.        
  46.         public Shape Shape {
  47.             get { return colShape; }
  48.         }
  49.        
  50.         public override Type ComponentType {
  51.             get { return null; }
  52.         }
  53.        
  54.         public override string Name {
  55.             get { return this.colShape.Name; }
  56.         }
  57.        
  58.         public override bool IsReadOnly {
  59.             get { return true; }
  60.         }
  61.        
  62.         public override Type PropertyType {
  63.             get { return this.colShape.IsNestedTable ? typeof(XPathDocumentView) : typeof(string); }
  64.         }
  65.        
  66.         public override bool CanResetValue(object o)
  67.         {
  68.             return false;
  69.         }
  70.        
  71.         public override object GetValue(object o)
  72.         {
  73.             if (null == o)
  74.                 throw new ArgumentNullException("XPathNodeViewPropertyDescriptor.GetValue");
  75.             XPathNodeView xiv = (XPathNodeView)o;
  76.             if (xiv.Collection.RowShape != this.rowShape)
  77.                 throw new ArgumentException("XPathNodeViewPropertyDescriptor.GetValue");
  78.             object val = xiv.Column(this.colIndex);
  79.             XPathNode nd = val as XPathNode;
  80.             if (null != nd) {
  81.                 XPathDocumentNavigator nav = new XPathDocumentNavigator(nd, null);
  82.                 XmlSchemaType xst = nd.SchemaType;
  83.                 XmlSchemaComplexType xsct = xst as XmlSchemaComplexType;
  84.                 if (null == xst || ((null != xsct) && xsct.IsMixed)) {
  85.                     return nav.InnerXml;
  86.                 }
  87.                 else {
  88.                     return nav.TypedValue;
  89.                 }
  90.             }
  91.             return val;
  92.         }
  93.        
  94.         public override void ResetValue(object o)
  95.         {
  96.             throw new NotImplementedException();
  97.         }
  98.        
  99.         public override void SetValue(object o, object value)
  100.         {
  101.             throw new NotImplementedException();
  102.         }
  103.        
  104.         public override bool ShouldSerializeValue(object o)
  105.         {
  106.             return false;
  107.         }
  108.     }
  109. }
  110. #endif

Developer Fusion