c544c019780e02862f7870db4d4a9cd76ac7e3ef
[mono.git] / mcs / class / System / System.ComponentModel / TypeConverter_2_1.cs
1 //
2 // TypeConverter for SL 2
3 //
4 // Copyright (C) 2008 Novell, Inc.
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the
8 // "Software"), to deal in the Software without restriction, including
9 // without limitation the rights to use, copy, modify, merge, publish,
10 // distribute, sublicense, and/or sell copies of the Software, and to
11 // permit persons to whom the Software is furnished to do so, subject to
12 // the following conditions:
13 // 
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the Software.
16 // 
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 //
25
26 #if MOONLIGHT
27
28 using System;
29 using System.Globalization;
30
31 namespace System.ComponentModel {
32
33         public class TypeConverter {
34
35                 public bool CanConvertFrom (Type sourceType)
36                 {
37                         return CanConvertFrom (null, sourceType);
38                 }
39
40                 public virtual bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
41                 {
42                         return false;
43                 }
44
45                 public object ConvertFrom (object value)
46                 {
47                         return ConvertFrom (null, CultureInfo.CurrentCulture, value);
48                 }
49
50                 public virtual object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
51                 {
52                         throw new NotImplementedException ();
53                 }
54
55                 public object ConvertFromString (string text)
56                 {
57                         return ConvertFrom (null, null, text);
58                 }
59
60                 public bool CanConvertTo (Type destinationType)
61                 {
62                         return CanConvertTo (null, destinationType);
63                 }
64
65                 public virtual bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
66                 {
67                         return false;
68                 }
69
70                 public object ConvertTo (object value, Type destinationType)
71                 {
72                         return ConvertTo (null, CultureInfo.CurrentCulture, value, destinationType);
73                 }
74
75                 public virtual object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
76                 {
77                         throw new NotImplementedException ();
78                 }
79
80                 public string ConvertToString (object value)
81                 {
82                         return (string) ConvertTo (null, CultureInfo.CurrentCulture, value, typeof(string));
83                 }
84         }
85 }
86
87 #endif