1 //
2 // System.Web.UI.WebControls.XmlDataSourceNodeDescriptor
3 //
4 // Authors:
5 //	Lluis Sanchez Gual (lluis@novell.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
8 //
9 
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 
31 using System;
32 using System.Collections;
33 using System.ComponentModel;
34 using System.Xml;
35 using System.Xml.XPath;
36 using System.Xml.Schema;
37 using AC = System.ComponentModel.AttributeCollection;
38 
39 namespace System.Web.UI.WebControls
40 {
41 	internal class XmlDataSourceNodeDescriptor: ICustomTypeDescriptor, IXPathNavigable
42 	{
43 		XmlNode node;
44 
XmlDataSourceNodeDescriptor(XmlNode node)45 		public XmlDataSourceNodeDescriptor (XmlNode node)
46 		{
47 			this.node = node;
48 		}
49 
50 		public XmlNode Node {
51 			get { return node; }
52 		}
53 
GetAttributes()54 		public AC GetAttributes()
55 		{
56 			return AC.Empty;
57 		}
58 
GetClassName()59 		public string GetClassName()
60 		{
61 			return "XmlDataSourceNodeDescriptor";
62 		}
63 
GetComponentName()64 		public string GetComponentName()
65 		{
66 			return null;
67 		}
68 
GetConverter()69 		public TypeConverter GetConverter()
70 		{
71 			return null;
72 		}
73 
GetDefaultEvent()74 		public EventDescriptor GetDefaultEvent()
75 		{
76 			return null;
77 		}
78 
GetDefaultProperty()79 		public PropertyDescriptor GetDefaultProperty()
80 		{
81 			return null;
82 		}
83 
GetEditor(Type editorBaseType)84 		public object GetEditor(Type editorBaseType)
85 		{
86 			return null;
87 		}
88 
GetEvents()89 		public EventDescriptorCollection GetEvents()
90 		{
91 			return null;
92 		}
93 
GetEvents(Attribute[] arr)94 		public EventDescriptorCollection GetEvents(Attribute[] arr)
95 		{
96 			return null;
97 		}
98 
GetProperties()99 		public PropertyDescriptorCollection GetProperties()
100 		{
101 			if (node.Attributes != null) {
102 				PropertyDescriptor[] props = new PropertyDescriptor [node.Attributes.Count];
103 				for (int n=0; n<props.Length; n++)
104 					props [n] = new XmlDataSourcePropertyDescriptor (node.Attributes [n].Name, node.IsReadOnly);
105 				return new PropertyDescriptorCollection (props);
106 			} else
107 				return PropertyDescriptorCollection.Empty;
108 		}
109 
GetProperties(Attribute[] arr)110 		public PropertyDescriptorCollection GetProperties(Attribute[] arr)
111 		{
112 			return GetProperties ();
113 		}
114 
GetPropertyOwner(PropertyDescriptor pd)115 		public object GetPropertyOwner (PropertyDescriptor pd)
116 		{
117 			if (pd is XmlDataSourcePropertyDescriptor)
118 				return this;
119 			return null;
120 		}
121 
CreateNavigator()122 		public XPathNavigator CreateNavigator ()
123 		{
124 			return node.CreateNavigator();
125 		}
126 	}
127 }
128 
129