public static void Modify1() { var id = 10; Expression <Func <User, bool> > expr = f => f.Id == id || f.Name == "ss"; Expression <Func <User, bool> > other = u => u.Name == "ds"; var expr2 = Expression.Lambda(expr.Body, Expression.Parameter(expr.Parameters[0].Type, "f2")); var pm = new ParameterUpdate(expr, "f3"); var expr3 = pm.Visit(expr); var modifier = new MyVisitor(); expr = (Expression <Func <User, bool> >)modifier.Modify(expr, other); var fn1 = expr.Compile(); }
private async Task <bool> UpdateParameter(EltraDevice device, Parameter parameter) { bool result = false; try { var parameterUpdate = new ParameterUpdate { ChannelId = Channel.Id, NodeId = device.NodeId, Parameter = parameter }; var path = $"api/parameter/update"; var json = parameterUpdate.ToJson(); var response = await Transporter.Put(_identity, Url, path, json); if (response != null) { if (response.StatusCode == HttpStatusCode.OK) { result = true; } else { MsgLogger.WriteError($"{GetType().Name} - UpdateParameter", $"update parameter '{parameter.UniqueId}' failed, reason = {response.StatusCode}"); } } else { MsgLogger.WriteError($"{GetType().Name} - UpdateParameter", $"update parameter '{parameter.UniqueId}' failed, reason = no response"); } } catch (Exception) { result = false; } return(result); }
/// <summary> /// ToJson /// </summary> /// <param name="update"></param> /// <returns></returns> public static string ToJson(this ParameterUpdate update) { return(JsonSerializer.Serialize(update)); }