public override object Instantiate(Type type, ILogPrinter inLogger) { var ctor = EmitHelper.CreateParameterlessConstructorHandler(type, inLogger); if (ctor == null) { return(null); } return(ctor()); }
public override object Instantiate(Type type, ILogPrinter inLogger) { Func <object> constructor; if (!constructorCache.TryGetValue(type.TypeHandle.Value, out constructor)) { constructor = EmitHelper.CreateParameterlessConstructorHandler(type, inLogger); if (constructor == null) { inLogger.LogError(string.Format("Cant create {0} object.", type.Name)); return(null); } constructorCache.Add(type.TypeHandle.Value, constructor); } return(constructor()); }