Exemplo n.º 1
0
 /// <summary>
 /// Make an IDref
 /// </summary>
 public static FhirElement ResolveReference(IdRef idRef, FhirElement context)
 {
     return(new FhirElement()
     {
         IdRef = idRef.Value
     }.ResolveReference(context));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Resolve reference
 /// </summary>
 public FhirElement ResolveReference(FhirElement context)
 {
     return(new FhirElement()
     {
         IdRef = this.Value
     }.ResolveReference(context));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Resolve the IDRef in this object to an identified object
        /// </summary>
        public FhirElement ResolveReference(FhirElement context)
        {
            // Check "this"
            if (context == null)
            {
                return(null);
            }
            else if (String.Format("#{0}", context.XmlId) == this.IdRef)
            {
                return(context);
            }
            else if (context.XmlId == this.IdRef)
            {
                return(context);
            }

            // Check each property
            foreach (var pi in context.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                object value = pi.GetValue(context, null);
                if (value is FhirElement) // Referencable
                {
                    var refValue = value as FhirElement;
                    if (String.Format("#{0}", refValue.XmlId) == this.IdRef)
                    {
                        return(refValue);
                    }
                    else
                    {
                        refValue = this.ResolveReference(refValue);
                        if (refValue != null)
                        {
                            return(refValue);
                        }
                    }
                }
                else if (value is IEnumerable)
                {
                    foreach (var val in value as IEnumerable)
                    {
                        var refValue = this.ResolveReference(val as FhirElement);
                        if (refValue != null)
                        {
                            return(refValue);
                        }
                    }
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Write table cell utility
        /// </summary>
        private void WriteTableCellInternal(XmlWriter w, FhirElement value, int colspan, int rowspan, string tagName, string style)
        {
            w.WriteStartElement(tagName, NS_XHTML);

            // CSS
            if (!String.IsNullOrEmpty(style))
            {
                w.WriteAttributeString("style", style);
            }
            if (colspan > 1)
            {
                w.WriteAttributeString("colspan", colspan.ToString());
            }
            if (rowspan > 1)
            {
                w.WriteAttributeString("rowspan", rowspan.ToString());
            }

            if (value != null)
            {
                value.WriteText(w);
            }
            w.WriteEndElement(); // td
        }
Exemplo n.º 5
0
 /// <summary>
 /// Write a table cell using the specified style
 /// </summary>
 protected void WriteTableCell(XmlWriter w, FhirElement value, int colspan, int rowspan, string style)
 {
     this.WriteTableCellInternal(w, value, colspan, rowspan, "td", style);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Write a table header
 /// </summary>
 protected void WriteTableHeader(XmlWriter w, FhirElement value, int colspan, int rowspan)
 {
     this.WriteTableCellInternal(w, value, colspan, rowspan, "th", null);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Write a table header
 /// </summary>
 protected void WriteTableCell(XmlWriter w, FhirElement value)
 {
     this.WriteTableCellInternal(w, value, 1, 1, "td", null);
 }