e79aa3c0ed
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
159 lines
5.7 KiB
C#
159 lines
5.7 KiB
C#
//------------------------------------------------------------------------------
|
|
// <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 |