csharp-eval-unity3d icon indicating copy to clipboard operation
csharp-eval-unity3d copied to clipboard

Matching functionality with Linq Eval

Open Ezzuna opened this issue 3 years ago • 1 comments

Hey, was really hoping you could help. I picked up this plugin to try and match functionality we had in place before moving over to the IL2CPP scripting backend.

The function I'm trying to replicate is as below.

LambdaParser.Linq.LambdaParse.Eval(string expr, IDictionary<string,object> vars) T Output = Assets.Scripts.SysExtensions.Extensions.TryCast<T>(res);

Using the above function with correct fed variables was matching my needed functionality perfectly. How would I go about achieving this in this plugin?

Thanks, Ezzuna.

Ezzuna avatar Feb 18 '22 16:02 Ezzuna

Hi @Ezzuna. Yes, you could use following code:

			var result = CSharp.CSharpExpression.Evaluate<int, int, int, int>
			(
				expression: "x + y + z",

				arg1: 2,
				arg1Name: "x",

				arg2: 3,
				arg2Name: "y",

				arg3: 10,
				arg3Name: "y"
			);

or pass object if you need more than 3 parameters.

deniszykov avatar Feb 18 '22 16:02 deniszykov