private XElement GetTypeTableCell(ElementDefinitionType[] types, SDTreeNode associatedTreeNode = null)
        {
            string result = string.Empty;

            if (types == null)
            {
                if (associatedTreeNode != null)
                {
                    ElementDefinition associatedElement = associatedTreeNode.Element;

                    if (associatedElement.nameReference != null)
                    {
                        if (!string.IsNullOrWhiteSpace(associatedElement.nameReference.value))
                        {
                            return(Html.Td("(see element " + associatedElement.nameReference.value + ")"));
                        }
                    }
                }

                return(Html.Td(string.Empty));
            }

            if (types.Length == 0)
            {
                return(Html.Td(string.Empty));
            }
            else if (types.Length == 1)
            {
                ElementDefinitionType type = types.Single();

                if (type.IsReference())
                {
                    return(Html.Td(GetReferenceTypeName(new ElementDefinitionType[] { type })));
                }
                else if (type.IsExtension())
                {
                    uri profileUri = type.profile.WhenNotNull(t => t.FirstOrDefault());

                    if (profileUri != null)
                    {
                        StructureDefinition structureDefinition = _resourceFileSet.GetStructureDefinition(profileUri.value);

                        if (structureDefinition.IsComplexExtension())
                        {
                            return(Html.Td("(complex extension)"));
                        }
                        else
                        {
                            ElementDefinitionType[] elementDefinitionTypes = structureDefinition.GetSimpleExtensionType();
                            return(GetTypeTableCell(elementDefinitionTypes));
                        }
                    }
                    else
                    {
                        return(Html.Td(string.Empty));
                    }
                }
                else
                {
                    return(Html.Td(GetNonReferenceTypeName(type)));
                }
            }
            else
            {
                if (types.All(t => t.IsReference()))
                {
                    return(Html.Td(GetReferenceTypeName(types)));
                }

                return(Html.Td(types.Select(t => GetNonReferenceTypeName(t)).Intersperse(" | ")));
            }
        }
Beispiel #2
0
        public SDNodeType GetNodeType()
        {
            if (IsSetupSlice)
            {
                return(SDNodeType.SetupSlice);
            }

            ElementDefinitionType[] types = GetElementDefinitionType();

            if (types != null)
            {
                if (types.Length == 0)
                {
                    return(SDNodeType.Unknown);
                }
                else if (types.Length == 1)
                {
                    ElementDefinitionType elementType = types.Single();

                    if (elementType.IsBackboneElement())
                    {
                        return(SDNodeType.Element);
                    }
                    else if (elementType.IsPrimitiveType())
                    {
                        return(SDNodeType.PrimitiveType);
                    }
                    else if (elementType.IsReference())
                    {
                        return(SDNodeType.Reference);
                    }
                    else if (elementType.IsComplexType())
                    {
                        return(SDNodeType.ComplexType);
                    }
                    else if (elementType.IsExtension())
                    {
                        if (ExtensionDefinition != null)
                        {
                            if (ExtensionDefinition.IsComplexExtension())
                            {
                                return(SDNodeType.ComplexExtension);
                            }
                        }

                        return(SDNodeType.SimpleExtension);
                    }
                    else if (elementType.IsResource())
                    {
                        return(SDNodeType.Resource);
                    }

                    return(SDNodeType.Unknown);
                }
                else
                {
                    if (types.Any(t => t.IsReference()))
                    {
                        return(SDNodeType.Reference);
                    }

                    return(SDNodeType.Choice);
                }
            }
            else if ((Element.PathBeforeSliceIndexing ?? string.Empty).EndsWith(".extension"))
            {
                // hacky but apparently only way to determine extensions within extensions

                return(SDNodeType.SimpleExtension);
            }
            else if (Element.nameReference != null)
            {
                return(SDNodeType.ReferenceToAnotherElement);
            }

            return(SDNodeType.Unknown);
        }