Provides several ways to create instances of the IExpression interface.
Namespace: Metalama.Framework.Code.SyntaxBuilders
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
public static class ExpressionFactory
Methods
Name | Description |
---|---|
Capture(dynamic?) | Creates a compile-time object that represents a run-time expression, i.e. the syntax or code, and not the result itself. The returned IExpression can then be used in run-time C# code thanks to the Value property. This mechanism allows to generate expressions that depend on a compile-time control flow. |
CastTo(IExpression, IType) | Returns an expression obtained by casting another expression to a type given as an IType. |
CastTo(IExpression, Type) | Returns an expression obtained by casting another expression to a type given as a Type. |
CastTo<T>(IExpression) | Returns an expression obtained by casting another expression to a type given as a generic parameter. |
Default() | Gets a |
Default(IType?) | Gets a |
Default(SpecialType) | Gets a |
Default(Type) | Gets a |
Default<T>() | Gets a |
Literal(byte, bool) | Returns an expression that represents a literal of type byte. |
Literal(decimal, bool) | Returns an expression that represents a literal of type decimal. |
Literal(double, bool) | Returns an expression that represents a literal of type double. |
Literal(short, bool) | Returns an expression that represents a literal of type short. |
Literal(int) | Returns an expression that represents a literal of type int. |
Literal(long, bool) | Returns an expression that represents a literal of type long. |
Literal(object?, bool) | Returns an expression that represents a literal. |
Literal(sbyte, bool) | Returns an expression that represents a literal of type sbyte. |
Literal(float, bool) | Returns an expression that represents a literal of type float. |
Literal(string?, bool) | Returns an expression that represents a literal of type string. |
Literal(ushort, bool) | Returns an expression that represents a literal of type ushort. |
Literal(uint, bool) | Returns an expression that represents a literal of type uint. |
Literal(ulong, bool) | Returns an expression that represents a literal of type ulong. |
Null() | Gets a |
Null(IType?) | Gets a |
Null(SpecialType) | Gets a |
Null(Type) | Gets a |
Null<T>() | Gets a |
Parse(string, IType?, bool?) | Parses a string containing a C# expression and returns an IExpression. The Value property allows to use this expression in a template. An alternative to this method is the ExpressionBuilder class. |
This() | Gets a |
This(INamedType) | Gets a |
WithNullability(IExpression, bool) | Returns the same expression, but assuming it has a different nullability. This method does not generate any cast (unlike CastTo(IExpression, IType)) and should only be used when the of the nullability given expression is wrongly infered. |
WithType(IExpression, IType) | Returns the same expression, but assuming it has a different type Type. This method does not generate any cast (unlike CastTo(IExpression, IType)) and should only be used when the of the type given expression is wrongly infered. |