public Vector MoveTo(Structure structure) { Vector clone = this.Clone(); clone.Structure = structure; clone.Element = structure.Root; return clone; }
/* public static Uri ResolvingUri(TypeRef typeref) { if (typeref.ProfileUri == null) { return BaseProfileUriFor(typeref.Code); } else { return new Uri(typeref.ProfileUri); } } */ public static Uri Identify(Structure structure, TypeRef typeref) { string name = typeref.Code; Uri uri; if ((name == "ResourceReference")) { uri = BaseProfileUriFor(name); } else if (typeref.ProfileUri != null) { if (typeref.ProfileUri.StartsWith("#")) { uri = new Uri(structure.ProfileUri + typeref.ProfileUri); } else if (typeref.ProfileUri != null) { uri = new Uri(typeref.ProfileUri); } else { uri = BaseProfileUriFor(name); } } else // typeref.profileuri == null { uri = BaseProfileUriFor(name); } return uri; }
private void _linkElements(Structure structure) { foreach (Element e in structure.Elements) { _tryLinkToParent(structure, e); } }
private void _linkElementRef(Structure structure, Element element) { if (element.ElementRef == null && element.ElementRefPath != null) { element.ElementRef = specification.GetElementByPath(structure, element.ElementRefPath); } }
static string StructureUri(string profileuri, string type, string name) { Structure structure = new Structure(); structure.Type = type; structure.Name = name; Uri uri = new Uri(profileuri); UriHelper.SetStructureIdentification(structure, uri); return structure.Uri.ToString(); }
private bool _tryLinkToParent(Structure structure, Element element) { Element parent = specification.ParentOf(structure, element); if (parent != null) { parent.Children.Add(element); return true; } return false; }
public static Vector Create(Structure structure, XPathNavigator node, XmlNamespaceManager nsm) { Vector vector = new Vector(); vector.Structure = structure; vector.Element = (structure != null) ? structure.Root : null; vector.Node = node; vector.NSM = nsm; vector.Origin = vector; return vector; }
public static Uri Identify(Structure structure) { string name = structure.Name ?? structure.Type; if (IsBaseProfile(structure.ProfileUri)) { return BaseProfileUriFor(name); } else { return AddAnchor(structure.ProfileUri, name); } }
public static void AddExtensionElement(Structure structure, Element parent = null) { parent = parent ?? structure.Root; string path = string.Format("{0}.extension", parent.Path); Element element = new Element(); element.Path = new Path(path); element.Name = "extension"; element.Cardinality = new Cardinality { Min = "0", Max = "*" }; TypeRef typeref = new TypeRef("Extension"); UriHelper.SetTypeRefIdentification(structure, typeref); element.TypeRefs.Add(typeref); structure.Elements.Add(element); }
public static Structure Primitive(string name, IPrimitiveValidator validator, string nsprefix = FhirNamespaceManager.Fhir) { Structure structure = new Structure(); structure.Type = name; UriHelper.SetStructureIdentification(structure, UriHelper.BASEPROFILE); Element element = new Element(); element.Path = new Path(name); element.Name = name; element.IsPrimitive = true; element.PrimitiveValidator = validator; element.Cardinality = new Cardinality { Min = "1", Max = "1" }; element.NameSpacePrefix = nsprefix; structure.Elements.Add(element); AddExtensionElement(structure, element); return structure; }
private void fixUris(Structure structure, Uri uri) { UriHelper.SetStructureIdentification(structure, uri); List<TypeRef> typerefs = structure.Elements.SelectMany(e => e.TypeRefs).ToList(); foreach (TypeRef t in typerefs) { UriHelper.SetTypeRefIdentification(structure, t); } }
public static void SetTypeRefIdentification(Structure structure, TypeRef typeref) { typeref.Uri = Identify(structure, typeref); }
private void HarvestElements(Profile.ProfileStructureComponent source, Structure target) { foreach(var element in source.Element) { target.Elements.Add(HarvestElement(element)); } }
public Element GetElementByPath(Structure structure, string path) { return structure.Elements.FirstOrDefault(element => element.Path.ToString() == path); }
public Element ParentOf(Structure structure, Element element) { Path path = element.Path.Parent(); Element parent = structure.Elements.Find(e => e.Path.Equals(path)); return parent; }
public Structure ReadStructure(XPathNavigator node) { Structure structure = new Structure(); structure.Type = node.SelectSingleNode("f:type/@value", ns).Value; structure.NameSpacePrefix = FhirNamespaceManager.Fhir; PreReadSlices(structure, node.Select("f:element", ns)); ReadStructureElements(structure, node.Select("f:element", ns)); return structure; }
public void ReadStructureElements(Structure structure, XPathNodeIterator xElements) { foreach (XPathNavigator xElement in xElements) { Element element = ReadElement(structure, xElement); structure.Elements.Add(element); } }
public Element ReadElement(Structure structure, XPathNavigator node) { Element element = new Element(); element.ID = id++; ReadElementDefinition(element, node); return element; }
public void PreReadSlices(Structure structure, XPathNodeIterator xNodes) { foreach (XPathNavigator node in xNodes) { if (IsSliceDefinitionNode(node)) { Slicing s = readSlicing(node); Slicings.Add(s); } } }
public IEnumerable <Structure> GetStructures(Uri uri) { Structure structure = GetStructure(uri); return(Singleton(structure)); }
public void ValidateElementRefs(Structure structure) { foreach(Element element in structure.Elements) { if (element.ElementRefPath != null && element.ElementRef == null) { Log(Group.Reference, Status.Failed, "Element [{0}] Name reference to different element [{1}] is unresolved", element.Path, element.ElementRefPath); } } }
public void ValidateStructure(Structure structure) { //if (structure.IsPrimitive) // return; // there is no more detail. foreach (Element element in structure.Elements) { ValidateElement(element); } ValidateElementRefs(structure); }
public void TrackStructure(Structure structure) { Uri uri = structure.ProfileUri; tracker.MarkResolved(uri); }
internal void Add(Structure structure) { AssertNotSealed(); _structures.Add(structure); }
public static void SetStructureIdentification(Structure structure, Uri uri) { structure.ProfileUri = uri.RemoveAnchor(); if (HasAnchor(uri)) { structure.Uri = uri; } else { structure.Uri = Identify(structure); } }
public Structure HarvestStructure(Profile.ProfileStructureComponent source, Uri uri) { Structure target = new Structure(); target.Name = source.Name; target.Type = source.Type; target.NameSpacePrefix = FhirNamespaceManager.Fhir; PrepareSlices(source); HarvestElements(source, target); fixUris(target, uri); return target; }
public Structure HarvestExtensionDefn(Profile.ProfileExtensionDefnComponent source) { Structure target = new Structure(); target.Name = source.Code; Element element = new Element(); element.Name = source.Code; HarvestElementDefinition(source.Definition, element); target.Elements.Add(element); return target; }