Ejemplo n.º 1
0
 public Vector MoveTo(Structure structure)
 {
     Vector clone = this.Clone();
     clone.Structure = structure;
     clone.Element = structure.Root;
     return clone;
 }
Ejemplo n.º 2
0
        /*
        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;
        }
Ejemplo n.º 3
0
 private void _linkElements(Structure structure)
 {
     foreach (Element e in structure.Elements)
     {
         _tryLinkToParent(structure, e);
     }
 }
Ejemplo n.º 4
0
 private void _linkElementRef(Structure structure, Element element)
 {
     if (element.ElementRef == null && element.ElementRefPath != null)
     {
         element.ElementRef = specification.GetElementByPath(structure, element.ElementRefPath);
     }
 }
Ejemplo n.º 5
0
 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();
 }
Ejemplo n.º 6
0
 private bool _tryLinkToParent(Structure structure, Element element)
 {
     Element parent = specification.ParentOf(structure, element);
     if (parent != null)
     {
         parent.Children.Add(element);
         return true;
     }
     return false;
 }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
0
 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);
     }
     
 }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
        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;
        }
Ejemplo n.º 11
0
 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);
     }
 }
Ejemplo n.º 12
0
 public static void SetTypeRefIdentification(Structure structure, TypeRef typeref)
 {
     typeref.Uri = Identify(structure, typeref);
 }
Ejemplo n.º 13
0
 private void HarvestElements(Profile.ProfileStructureComponent source, Structure target)
 {
     foreach(var element in source.Element)
     {
         target.Elements.Add(HarvestElement(element));
     }
 }
Ejemplo n.º 14
0
 public Element GetElementByPath(Structure structure, string path)
 {
     return structure.Elements.FirstOrDefault(element => element.Path.ToString() == path);
 }
Ejemplo n.º 15
0
 public Element ParentOf(Structure structure, Element element)
 {
     Path path = element.Path.Parent();
     Element parent = structure.Elements.Find(e => e.Path.Equals(path));
     return parent;
 }
Ejemplo n.º 16
0
 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;
 }
Ejemplo n.º 17
0
 public void ReadStructureElements(Structure structure, XPathNodeIterator xElements)
 {
     foreach (XPathNavigator xElement in xElements)
     {
         Element element = ReadElement(structure, xElement);
         structure.Elements.Add(element);
     }
 }
Ejemplo n.º 18
0
 public Element ReadElement(Structure structure, XPathNavigator node)
 {
     Element element = new Element();
     element.ID = id++;
     
     ReadElementDefinition(element, node);
     return element;
 }
Ejemplo n.º 19
0
 public void PreReadSlices(Structure structure, XPathNodeIterator xNodes)
 {
     foreach (XPathNavigator node in xNodes)
     {
         if (IsSliceDefinitionNode(node))
         {
             Slicing s = readSlicing(node);
             Slicings.Add(s);
         }
     }
 }
Ejemplo n.º 20
0
        public IEnumerable <Structure> GetStructures(Uri uri)
        {
            Structure structure = GetStructure(uri);

            return(Singleton(structure));
        }
Ejemplo n.º 21
0
 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);
         }
     }
 }
Ejemplo n.º 22
0
        public void ValidateStructure(Structure structure)
        {
            //if (structure.IsPrimitive)
             //   return; // there is no more detail.

            foreach (Element element in structure.Elements)
            {
                ValidateElement(element);
            }

            ValidateElementRefs(structure);
        }
Ejemplo n.º 23
0
        public void TrackStructure(Structure structure)
        {
            Uri uri = structure.ProfileUri;

            tracker.MarkResolved(uri);
        }
Ejemplo n.º 24
0
 internal void Add(Structure structure)
 {
     AssertNotSealed();
     _structures.Add(structure);
 }
Ejemplo n.º 25
0
 public static void SetStructureIdentification(Structure structure, Uri uri)
 {
     structure.ProfileUri = uri.RemoveAnchor();
     if (HasAnchor(uri))
     {
         structure.Uri = uri;
     }
     else
     {
         structure.Uri = Identify(structure);
     }
 }
Ejemplo n.º 26
0
 public static void SetTypeRefIdentification(Structure structure, TypeRef typeref)
 {
     typeref.Uri = Identify(structure, typeref);
 }
Ejemplo n.º 27
0
 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;
 }
Ejemplo n.º 28
0
 public void TrackStructure(Structure structure)
 {
     Uri uri = structure.ProfileUri;
     tracker.MarkResolved(uri);
 }
Ejemplo n.º 29
0
 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;
 }