private bool Ubicar(object[] intervalo,TProblemaParametro p) { if (p.Valor >= double.Parse(intervalo[0].ToString()) && p.Valor<= double.Parse(intervalo[1].ToString())) { return true; } return false; }
//Parsers public List<TProblemaParametro> ParseParametros(string json) { List<TProblemaParametro> final = new List<TProblemaParametro>(); char[] separador = {':', ']'}; List<int> ids = new List<int>(); List<double> valores = new List<double>(); string[] res = json.Split(separador, StringSplitOptions.RemoveEmptyEntries); List<string> re1 = new List<string>(); for (int i = 1; i < res.Length; i+=2) { re1.Add(res[i]); } if (re1.Count > 0) { foreach (var VARIABLE in re1) { char[] separador1 = {','}; string[] x = VARIABLE.Split(separador1); string num = ""; string value = ""; for (int i = 0; i < x[0].Count(); i++) { if (x[0][i] != '/' && x[0][i] != '"' && x[0][i] != '[' && x[0][i] != ']') { num += x[0][i]; } } for (int i = 0; i < x[3].Count(); i++) { if (x[3][i] != '/' && x[3][i] != '"' && x[3][i] != '[' && x[3][i] != ']') { value += x[3][i]; } } ids.Add(int.Parse(num)); valores.Add(double.Parse(value.Replace(".",","))); } } if (ids.Count > 0) { for (int i = 0; i < ids.Count; i++) { TProblemaParametro t = new TProblemaParametro(); t.IdParametro = ids[i]; t.Valor = valores[i]; final.Add(t); } } return final; }