Example #1
0
    public static object Instantiate(Type type)
    {
        Func <object> constructor;

        if (!constructorCache.TryGetValue(type.TypeHandle.Value, out constructor))
        {
            constructor = EmitHelper.CreateParameterlessConstructorHandler(type);
            constructorCache.Add(type.TypeHandle.Value, constructor);
        }

        return(constructor());
    }