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

◆ Constant() [2/2]

static ConstantExpression System.Linq.Expressions.Expression< TDelegate >.Constant ( object? value,
Type type )
inlinestaticinherited

Definition at line 2373 of file Expression.cs.

2374 {
2376 TypeUtils.ValidateType(type, "type");
2377 if (value == null)
2378 {
2379 if (type == typeof(object))
2380 {
2381 return new ConstantExpression(null);
2382 }
2383 if (!type.IsValueType || type.IsNullableType())
2384 {
2385 return new TypedConstantExpression(null, type);
2386 }
2387 }
2388 else
2389 {
2390 Type type2 = value.GetType();
2391 if (type == type2)
2392 {
2393 return new ConstantExpression(value);
2394 }
2395 if (type.IsAssignableFrom(type2))
2396 {
2397 return new TypedConstantExpression(value, type);
2398 }
2399 }
2400 throw Error.ArgumentTypesMustMatch();
2401 }
static void RequiresNotNull(object value, string paramName)
static void ValidateType(Type type, string paramName)
Definition TypeUtils.cs:695

References System.Linq.Expressions.Error.ArgumentTypesMustMatch(), System.Dynamic.Utils.ContractUtils.RequiresNotNull(), System.type, System.Dynamic.Utils.TypeUtils.ValidateType(), and System.value.