예제 #1
0
        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();
        }
예제 #2
0
        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);
        }
예제 #3
0
 /// <summary>
 /// ToJson
 /// </summary>
 /// <param name="update"></param>
 /// <returns></returns>
 public static string ToJson(this ParameterUpdate update)
 {
     return(JsonSerializer.Serialize(update));
 }