/// <summary> /// Gets all element descriptors that are valid at the given document node. /// </summary> private IEnumerable <ElementDescriptor> GetElementDescriptors(List <string> path, bool getChildren) { IElementDescriptorProvider provider = DescriptorProvider; if (provider == null) { return(Enumerable.Empty <ElementDescriptor>()); } if ((path == null) || (path.Count == 0)) { return(provider.Descriptors); } // Walk towards the given node, as element descriptor provider. foreach (var name in path) { provider = provider.Descriptors.FirstOrDefault(x => x.Name == name); if (provider == null) { return(Enumerable.Empty <ElementDescriptor>()); } } if (getChildren) { return(provider.Descriptors); } var descriptor = provider as ElementDescriptor; if (descriptor == null) { return(Enumerable.Empty <ElementDescriptor>()); } return(new[] { descriptor }); }
/// <summary> /// Gets the attribute descriptor that is valid for the given attribute. /// </summary> private AttributeDescriptor GetAttributeDescriptor(List <string> path, string localName) { IElementDescriptorProvider provider = DescriptorProvider; if (provider == null) { return(null); } var nodeDescriptor = GetElementDescriptors(path, false).FirstOrDefault(); if (nodeDescriptor == null) { return(null); } return(nodeDescriptor.Attributes.FirstOrDefault(x => x.Name == localName)); }