2 // System.ComponentModel.TypeConverter
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (C) 2002 Ximian, Inc (http://www.ximian.com)
11 using System.Collections;
12 using System.Globalization;
14 namespace System.ComponentModel {
16 public class TypeConverter
18 public TypeConverter ()
22 public bool CanConvertFrom (Type sourceType)
24 return CanConvertFrom (null, sourceType);
28 public virtual bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
30 throw new NotImplementedException ();
33 public bool CanConvertTo (Type destinationType)
35 return CanConvertTo (null, destinationType);
39 public virtual bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
41 throw new NotImplementedException ();
44 public object ConvertFrom (object o)
46 return ConvertFrom (null, CultureInfo.CurrentCulture, o);
50 public virtual object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
52 throw new NotImplementedException ();
55 public virtual object ConvertFromInvariantString (string text)
57 return ConvertFromInvariantString (null, text);
61 public virtual object ConvertFromInvariantString (ITypeDescriptorContext context, string text)
63 throw new NotImplementedException ();
66 public object ConvertFromString (string s)
68 return ConvertFrom (s);
71 public object ConvertFromString (ITypeDescriptorContext context, string text)
73 return ConvertFromString (context, CultureInfo.CurrentCulture, text);
77 public object ConvertFromString (ITypeDescriptorContext context, CultureInfo culture, string text)
79 throw new NotImplementedException ();
83 public object ConvertTo (object value, Type destinationType)
85 throw new NotImplementedException ();
88 public virtual object ConvertTo (ITypeDescriptorContext context,
93 throw new NotImplementedException ();
97 public string ConvertToInvariantString (object value)
99 throw new NotImplementedException ();
103 public string ConvertToInvariantString (ITypeDescriptorContext context, object value)
105 throw new NotImplementedException ();
109 public string ConvertToString (object value)
111 throw new NotImplementedException ();
115 public string ConvertToString (ITypeDescriptorContext context, object value)
117 throw new NotImplementedException ();
121 public string ConvertToString (ITypeDescriptorContext context, CultureInfo culture, object value)
123 throw new NotImplementedException ();
127 public object CreateInstance (IDictionary propertyValues)
129 throw new NotImplementedException ();
133 public virtual object CreateInstance (ITypeDescriptorContext context, IDictionary propertyValues)
135 throw new NotImplementedException ();
139 public bool GetCreateInstanceSupported ()
141 throw new NotImplementedException ();
145 public virtual bool GetCreateInstanceSupported (ITypeDescriptorContext context)
147 throw new NotImplementedException ();
151 public PropertyDescriptorCollection GetProperties (object value)
153 throw new NotImplementedException ();
157 public PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context, object value)
159 throw new NotImplementedException ();
163 public virtual PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context,
165 Attribute[] attributes)
167 throw new NotImplementedException ();
171 public bool GetPropertiesSupported ()
173 throw new NotImplementedException ();
177 public virtual bool GetPropertiesSupported (ITypeDescriptorContext context)
179 throw new NotImplementedException ();
183 public ICollection GetStandardValues ()
185 throw new NotImplementedException ();
189 public virtual StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
191 throw new NotImplementedException ();
195 public bool GetStandardValuesExclusive ()
197 throw new NotImplementedException ();
201 public virtual bool GetStandardValuesExclusive (ITypeDescriptorContext context)
203 throw new NotImplementedException ();
207 public bool GetStandardValuesSupported ()
209 throw new NotImplementedException ();
213 public virtual bool GetStandardValuesSupported (ITypeDescriptorContext context)
215 throw new NotImplementedException ();
219 public bool IsValid (object value)
221 throw new NotImplementedException ();
225 public virtual bool IsValid (ITypeDescriptorContext context, object value)
227 throw new NotImplementedException ();
230 public class StandardValuesCollection : ICollection, IEnumerable
232 private ICollection values;
234 public StandardValuesCollection (ICollection values)
236 this.values = values;
239 public void CopyTo (Array array, int index)
241 values.CopyTo (array, index);
244 public IEnumerator GetEnumerator ()
246 return values.GetEnumerator ();
249 bool ICollection.IsSynchronized
251 get { return false; }
254 object ICollection.SyncRoot
259 int ICollection.Count
261 get { return this.Count; }
266 get { return values.Count; }
269 public object this [int index]
271 get { return ((IList) values) [index]; }
275 protected abstract class SimplePropertyDescriptor : PropertyDescriptor
277 private Type componentType;
278 private Type propertyType;
280 public SimplePropertyDescriptor (Type componentType,
283 this (componentType, name, propertyType, new Attribute [0])
287 public SimplePropertyDescriptor (Type componentType,
290 Attribute [] attributes) : base (name, attributes)
292 this.componentType = componentType;
293 this.propertyType = propertyType;
296 public override Type ComponentType
298 get { return componentType; }
301 public override Type PropertyType
303 get { return propertyType; }
306 public override bool IsReadOnly
309 return Attributes.Contains (ReadOnlyAttribute.Yes);