From: Mike R. <mik...@us...> - 2005-03-07 05:46:20
|
Update of /cvsroot/netreflector/NetReflector/src/NetReflector/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21723/src/NetReflector/util Modified Files: ReflectionUtil.cs Added Files: DefaultInstantiator.cs IInstantiator.cs Log Message: Allowing Custom Instantiators to be used (used by CruiseControl.NET's Web Dashboard project) Index: ReflectionUtil.cs =================================================================== RCS file: /cvsroot/netreflector/NetReflector/src/NetReflector/util/ReflectionUtil.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReflectionUtil.cs 15 Nov 2004 05:13:03 -0000 1.3 --- ReflectionUtil.cs 7 Mar 2005 05:46:05 -0000 1.4 *************** *** 12,28 **** return (t.IsPrimitive || t == typeof(string) || t == typeof(DateTime) || t.IsSubclassOf(typeof(Enum))); } - - public static object CreateInstance(Type type) - { - try - { - return type.Assembly.CreateInstance(type.FullName); - } - catch (Exception e) - { - string message = StringUtil.Format("Unable to create an instance of reflected type '{0}'. Please verify that this object has a default constructor.", type); - throw new NetReflectorException(message, e); - } - } } } --- 12,15 ---- --- NEW FILE: DefaultInstantiator.cs --- using System; using Exortech.NetReflector.Util; namespace Exortech.NetReflector.Util { public class DefaultInstantiator : IInstantiator { public object Instantiate(Type type) { try { return type.Assembly.CreateInstance(type.FullName); } catch (Exception e) { string message = StringUtil.Format("Unable to create an instance of reflected type '{0}'. Please verify that this object has a default constructor.", type); throw new NetReflectorException(message, e); } } } } --- NEW FILE: IInstantiator.cs --- using System; namespace Exortech.NetReflector.Util { public interface IInstantiator { object Instantiate(Type type); } } |