#if SILVERLIGHT
namespace Caliburn.Micro {
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
///
/// Provides information about the characteristics for a component, such as its attributes, properties, and events. This class cannot be inherited.
///
public static class TypeDescriptor {
static readonly Dictionary Cache = new Dictionary();
///
/// Returns a type converter for the specified type.
///
/// The System.Type of the target component.
/// A System.ComponentModel.TypeConverter for the specified type.
public static TypeConverter GetConverter(Type type) {
TypeConverter converter;
if(!Cache.TryGetValue(type, out converter)) {
var customAttributes = type.GetAttributes(true);
if (!customAttributes.Any()) {
return new TypeConverter();
}
converter = Activator.CreateInstance(Type.GetType(customAttributes.First().ConverterTypeName)) as TypeConverter;
Cache[type] = converter;
}
return converter;
}
}
}
#endif