Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static Delegate CompileConstructor<TNew>(params Type[] types)
- {
- ConstructorInfo ctor = typeof(TNew).GetConstructor(types);
- var parameters = ctor.GetParameters().Select(
- x => Expression.Parameter(x.ParameterType, x.Name));
- var newx = Expression.New(ctor, parameters);
- return Expression.Lambda(newx, parameters).Compile();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement