1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
//------------------------------------------------------------------------------
// <copyright file="XPathNodeView.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// <owner current="true" primary="true">derekdb</owner>
//------------------------------------------------------------------------------
#if ENABLEDATABINDING
using System;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Schema;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
namespace System.Xml.XPath.DataBinding
{
public sealed class XPathNodeView : IXPathNavigable, ICustomTypeDescriptor, INotifyPropertyChanged {
XPathDocumentView collection;
XPathNode rowNd;
object[] cols;
internal XPathNodeView(XPathDocumentView col, XPathNode rowNd, object[] columns) {
this.collection = col;
this.rowNd = rowNd;
this.cols = columns;
}
//
// local methods
public XPathDocumentView XPathDocumentView {
get { return this.collection; }
}
public object this[string fieldname] {
get {
if (null == fieldname)
throw new ArgumentNullException("fieldname");
int col = this.collection.RowShape.FindNamedSubShape(fieldname);
if (col == -1)
throw new ArgumentException("fieldname");
Debug.Assert(col >= 0 && col < this.cols.Length);
return this.cols[col];
}
set {
throw new NotSupportedException();
}
}
public object this[int fieldIndex] {
get {
if (fieldIndex < 0 || fieldIndex >= this.cols.Length)
throw new ArgumentOutOfRangeException("fieldIndex");
return this.cols[fieldIndex];
}
set {
throw new NotSupportedException();
}
}
//
// IXPathNavigable Implementation
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.CreateNavigator"]/*' />
public XPathNavigator CreateNavigator() {
XPathNode nd = this.rowNd;
if (null != nd)
return new XPathDocumentNavigator(this.rowNd, null);
return null;
}
//
// ICustomTypeDescriptor Implementation
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetAttributes"]/*' />
public AttributeCollection GetAttributes() {
return new AttributeCollection((Attribute[])null);
}
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetClassName"]/*' />
public String GetClassName() {
return collection.RowShape.Name;
}
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetComponentName"]/*' />
public String GetComponentName() {
return null;
}
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetConverter"]/*' />
public TypeConverter GetConverter() {
return null;
}
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetDefaultEvent"]/*' />
public EventDescriptor GetDefaultEvent() {
return null;
}
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetDefaultProperty"]/*' />
public PropertyDescriptor GetDefaultProperty() {
return null;
}
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetEditor"]/*' />
public object GetEditor(Type editorBaseType) {
return null;
}
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetEvents"]/*' />
public EventDescriptorCollection GetEvents() {
return null;
}
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetEvents2"]/*' />
public EventDescriptorCollection GetEvents(Attribute[] attributes) {
return null;
}
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetPropertyOwner"]/*' />
public object GetPropertyOwner(PropertyDescriptor pd) {
return null;
}
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetProperties"]/*' />
public PropertyDescriptorCollection GetProperties() {
return collection.GetItemProperties(null);
}
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.GetProperties2"]/*' />
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) {
return collection.GetItemProperties(null);
}
//
// INotifyPropertyChanged Implementation
/// <include file='doc\XPathNodeView.uex' path='docs/doc[@for="XPathNodeView.PropertyChanged"]/*' />
public event PropertyChangedEventHandler PropertyChanged {
add {
throw new NotSupportedException("INotifyPropertyChanged.PropertyChanged");
}
remove {
throw new NotSupportedException("INotifyPropertyChanged.PropertyChanged");
}
}
//
// internal implementation
// used by XPathNodeViewPropertyDescriptor to access values
internal XPathDocumentView Collection { get { return this.collection; } }
internal object Column(int index) { return cols[index]; }
}
}
#endif
|