private bool ParseJArrayItem(JToken jNode, DeleteCondition dc) { switch (jNode.Type) { case JTokenType.Object: JToken[] jssubNodes = (jNode as JObject).Children().ToArray(); foreach (JToken jssub in jssubNodes) { if (CheckDeleteCondition(jssub, dc)) { return(true); } } break; case JTokenType.Array: JToken[] jsaubNodes = (jNode as JArray).Children().ToArray(); foreach (JToken jssub in jsaubNodes) { if (ParseJArrayItem(jssub, dc)) { return(false); } } break; case JTokenType.Property: if (CheckDeleteCondition(jNode, dc)) { return(true); } break; } return(false); }
private bool SelectedChildrenNode(XmlNode node, DeleteCondition dc) { if (node.Name == dc.Child.Name) { if (JudgeCondition(node, dc)) { return(true); } } else { foreach (XmlNode xn in node.ChildNodes.OfType <XmlElement>()) { if (xn.Name == dc.Child.Name) { if (JudgeCondition(xn, dc)) { return(true); } } else { if (SelectedChildrenNode(xn, dc)) { return(true); } } } } return(false); }
public object Clone() { DeleteCondition result = new DeleteCondition(); result.Child = this.Child.Clone() as CNode; result.DeleteConditionString = this.DeleteConditionString; result.DeleteConditionType = this.DeleteConditionType; return(result as object); }
private bool JudgeCondition(XmlNode node, DeleteCondition dc) { bool result = false; if (dc.DeleteConditionType == ConditionType.Equal) { if (string.Equals(node.InnerText, dc.Value)) { result = true; } } else { if (dc.DeleteConditionType == ConditionType.Less) { int v = int.Parse(dc.Value); int d = 0; if (int.TryParse(node.InnerText, out d)) { if (v > d) { result = true; } } } else { int v = int.Parse(dc.Value); int d = 0; if (int.TryParse(node.InnerText, out d)) { if (v < d) { result = true; } } } } return(result); }
private bool CheckDeleteCondition(JToken jNode, DeleteCondition dc) { if (jNode.Type == JTokenType.Property) { JProperty jp = jNode as JProperty; if (jp.Name == dc.Child.Name) { if (dc.DeleteConditionType == ConditionType.Equal) { if (jp.ToString().IndexOf(dc.Value) > -1) { return(true); } } else { if (dc.DeleteConditionType == ConditionType.Less) { double v = 0d; if (double.TryParse(jp.Value.ToString(), out v)) { if (v < double.Parse(dc.Value)) { return(true); } } } else { double v = 0d; if (double.TryParse(jp.Value.ToString(), out v)) { if (v > double.Parse(dc.Value)) { return(true); } } } } } } JToken[] jSubNodes = jNode.Children().ToArray(); foreach (JToken jSub in jSubNodes) { switch (jSub.Type) { case JTokenType.Object: JToken[] jssubNodes = (jSub as JObject).Children().ToArray(); foreach (JToken jssub in jssubNodes) { if (CheckDeleteCondition(jssub, dc)) { return(true); } } break; case JTokenType.Array: JToken[] jsaubNodes = (jSub as JArray).Children().ToArray(); foreach (JToken jssub in jsaubNodes) { if (ParseJArrayItem(jssub, dc)) { return(true); } } break; case JTokenType.Property: if (CheckDeleteCondition(jSub, dc)) { return(true); } break; } } return(false); }