public static void Match(this GroupElement element, Action <AndElement> and, Action <OrElement> or) { if (element == null) { throw new ArgumentNullException(nameof(element), "Group element cannot be null"); } if (element is AndElement) { and.Invoke((AndElement)element); } else if (element is OrElement) { or.Invoke((OrElement)element); } else { throw new ArgumentOutOfRangeException(nameof(element), $"Unsupported group element. ElementType={element.GetType()}"); } }
public static void Match(this GroupElement element, Action <AndElement> and, Action <OrElement> or, Action <NotElement> not, Action <ExistsElement> exists) { if (element == null) { throw new ArgumentNullException("element", "Rule element cannot be null"); } else if (element is AndElement) { and.Invoke((AndElement)element); } else if (element is OrElement) { or.Invoke((OrElement)element); } else if (element is NotElement) { not.Invoke((NotElement)element); } else if (element is ExistsElement) { exists.Invoke((ExistsElement)element); } else { throw new ArgumentOutOfRangeException("element", string.Format("Unsupported rule group element. ElementType={0}", element.GetType())); } }