Added helper method for creating TypeCreators.

This commit is contained in:
Paul Knopf 2018-08-04 11:31:38 -04:00
parent 056e8037a6
commit 631ebe508f

View file

@ -20,5 +20,25 @@ namespace Qml.Net
}
return Activator.CreateInstance(type);
}
public static ITypeCreator FromDelegate(Func<Type, object> func)
{
return new DelegateTypeCreator(func);
}
class DelegateTypeCreator : ITypeCreator
{
private readonly Func<Type, object> _func;
public DelegateTypeCreator(Func<Type, object> func)
{
_func = func;
}
public object Create(Type type)
{
return _func(type);
}
}
}
}