Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ New() [1/6]

static NewExpression System.Linq.Expressions.Expression< TDelegate >.New ( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type)
inlinestaticinherited

Definition at line 4506 of file Expression.cs.

4507 {
4509 if (type == typeof(void))
4510 {
4511 throw Error.ArgumentCannotBeOfTypeVoid("type");
4512 }
4513 TypeUtils.ValidateType(type, "type");
4514 ConstructorInfo constructorInfo = type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SingleOrDefault((ConstructorInfo c) => c.GetParametersCached().Length == 0);
4515 if (constructorInfo != null)
4516 {
4517 return New(constructorInfo);
4518 }
4519 if (!type.IsValueType)
4520 {
4521 throw Error.TypeMissingDefaultConstructor(type, "type");
4522 }
4523 return new NewValueTypeExpression(type, EmptyReadOnlyCollection<Expression>.Instance, null);
4524 }
static void RequiresNotNull(object value, string paramName)
static void ValidateType(Type type, string paramName)
Definition TypeUtils.cs:695

References System.Linq.Expressions.Error.ArgumentCannotBeOfTypeVoid(), System.Reflection.Instance, System.Linq.Expressions.New, System.Dynamic.Utils.ContractUtils.RequiresNotNull(), System.type, System.Linq.Expressions.Error.TypeMissingDefaultConstructor(), and System.Dynamic.Utils.TypeUtils.ValidateType().