I am currently working on a little thing in Silverlight and came across an interesting “feature”. The thing I am working on requires me to dynamically create types based on strings in a configuration file, and for this purpose, I created a simple TypeConverter called TypeTypeConverter. It is a very simple converter that takes a string and converts it to a Type. So I created a very simple implementation that looks like this
public class TypeTypeConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value is string)
{
return Type.GetType((string)value, true);
}
return base.ConvertFrom(context, culture, value);
}
}
As you can see, it is probably a little TOO simple as it doesn’t handle errors at all. But to be honest, in my case it is actually a bit by design.
So why does this simple little thing end up on my blog? Well, because it failed… Not the code as such, but the thing I was trying to do…
More...
10. November 2009
ZeroKoll
Silverlight
I’m currently working on some cool demos for PDC09. Unfortunately, I can’t talk about them yet, but I can tell you some interesting things that I have found along the way. Since I do a lot of different development on a lot of different projects, most of my projects are built inside a VM. This makes it really easy to keep the projects separate and keeps the host machine clean. However, Hyper-V seems to kill the performance of graphics intensive tasks. So, Blend work is really slow. And besides, I’m among other things running some things that work with Azure, which is kind of slow. So I have opted for a solution where I share the Silverlight project between my VM and my host, making it possible for me to do the graphically intensive things on the host, but keep the source and source control in the VM.
More...