Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TypeDescriptor.cs « System.ComponentModel « System « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f3d9af4b36162c4e89ed157b1eca85d52d780073 (plain)
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
//
// System.ComponentModel.TypeDescriptor
//
// Authors:
//	Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) 2002 Ximian, Inc (http://www.ximian.com)
//

using System;

namespace System.ComponentModel
{

[MonoTODO("Only implemented the minimal features needed to use ColorConverter")]
public sealed class TypeDescriptor
{
	public static TypeConverter GetConverter (Type type)
	{
		object [] attrs = type.GetCustomAttributes (false);
		string converter_name = null;
		foreach (object o in attrs){
			if (o is TypeConverterAttribute){
				TypeConverterAttribute tc = (TypeConverterAttribute) o;
				converter_name = tc.ConverterTypeName;
				break;
			}
		}

		if (converter_name == null)
			return null;

		object converter = null;
		try {
			converter = Activator.CreateInstance (Type.GetType (converter_name));
		} catch (Exception){
		}
	
		return converter as TypeConverter;
	}
}
}