private IEnumerable <TypedElementNode> enumerateElements(ElementDefinitionSummaryCache dis, ISourceNode parent, string name) { IEnumerable <ISourceNode> childSet = null; // no name filter: work on all the parent's children if (name == null) { childSet = parent.Children(); } else { var hit = dis.TryGetBySuffixedName(name, out var info); childSet = hit && info.IsChoiceElement ? parent.Children(name + "*") : parent.Children(name); } string lastName = null; int _nameIndex = 0; foreach (var scan in childSet) { var hit = dis.TryGetBySuffixedName(scan.Name, out var info); NavigatorPosition match = info == null ? new NavigatorPosition(scan, null, scan.Name, null) : deriveInstanceType(scan, info); // If we found a type, but we don't know about the specific child, complain if (dis != ElementDefinitionSummaryCache.Empty && !match.IsTracking) { raiseTypeError($"Encountered unknown element '{scan.Name}' while parsing", this, warning: _settings.ErrorMode != TypedElementSettings.TypeErrorMode.Report); // don't include member, unless we are explicitly told to let it pass if (_settings.ErrorMode != TypedElementSettings.TypeErrorMode.Passthrough) { continue; } } if (lastName == scan.Name) { _nameIndex += 1; } else { _nameIndex = 0; lastName = scan.Name; } var prettyPath = hit && !info.IsCollection ? $"{ShortPath}.{match.Name}" : $"{ShortPath}.{match.Name}[{_nameIndex}]"; yield return(new TypedElementNode(this, match, prettyPath)); } }
private ElementDefinitionSummaryCache down(NavigatorPosition current) { if (!current.IsTracking || current.InstanceType == null) { return(ElementDefinitionSummaryCache.Empty); } // If this is a backbone element, the child type is the nested complex type if (current.SerializationInfo.Type[0] is IStructureDefinitionSummary be) { return(ElementDefinitionSummaryCache.ForType(be)); } else { var si = Provider.Provide(current.InstanceType); return(si == null ? ElementDefinitionSummaryCache.Empty : ElementDefinitionSummaryCache.ForType(si)); } }