/// <summary> /// This turn a call to TryGetParemeter('item') where item is a local variable /// into a WrapIfNull(item) method call. /// </summary> /// <param name="node">The node.</param> public override void OnMethodInvocationExpression(MethodInvocationExpression node) { var expression = node.Target as ReferenceExpression; if (expression == null || expression.Name != "TryGetParameter") { base.OnMethodInvocationExpression(node); return; } var name = ((StringLiteralExpression)node.Arguments[0]).Value; var entity = NameResolutionService.Resolve(name); if (entity == null) { base.OnMethodInvocationExpression(node); return; } var parentNode = node.ParentNode; var mie = CodeBuilder.CreateMethodInvocation( CodeBuilder.CreateSelfReference(_currentMethod.DeclaringType), wrapNullValue); var item = new ReferenceExpression(node.LexicalInfo, name); TypeSystemServices.Bind(item, entity); mie.Arguments.Add(item); parentNode.Replace(node, mie); }