/// <summary>Adds a complex to 'complex'.</summary> /// <param name="elements"> The elements.</param> /// <param name="complex"> The complex.</param> /// <param name="complexType">Type of the complex.</param> private void AddComplex( Dictionary <string, CytoElement> elements, FhirComplex complex, FhirNodeInfo.FhirNodeType complexType) { if (elements.ContainsKey(complex.Name)) { elements[complex.Name].Data.Weight += _weightIncrement; if (elements[complex.Name].Data.Weight > _maxNodeWeight) { _maxNodeWeight = (decimal)elements[complex.Name].Data.Weight; } return; } CytoElement cy = new CytoElement() { Group = CytoElement.GroupNodes, Data = new CytoElementDataNode() { Id = complex.Name, Name = complex.Name, Weight = _weightIncrement, Group = _nodeGroupMap[complexType], }, }; elements.Add(complex.Name, cy); TryRecurse( elements, complex.Name, complexType, complex.BaseTypeName); AddElementEdges(elements, complex, complex); if (complex.Components != null) { foreach (FhirComplex component in complex.Components.Values) { AddElementEdges(elements, complex, component); } } }
/// <summary>Adds an edge.</summary> /// <param name="elements"> The elements.</param> /// <param name="source"> Source for the.</param> /// <param name="sourceType">Type of the source.</param> /// <param name="target"> Target for the.</param> /// <param name="targetType">Type of the target.</param> private static void AddEdge( Dictionary <string, CytoElement> elements, string source, FhirNodeInfo.FhirNodeType sourceType, string target, FhirNodeInfo.FhirNodeType targetType) { if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(target)) { return; } if (source == target) { return; } string id = $"{source}-{target}"; if (elements.ContainsKey(id)) { elements[id].Data.Weight += _weightIncrement; if (elements[id].Data.Weight > _maxEdgeWeight) { _maxEdgeWeight = (decimal)elements[id].Data.Weight; } return; } CytoElement cy = new CytoElement() { Group = CytoElement.GroupEdges, Data = new CytoElementDataEdge() { Id = id, SourceId = source, TargetId = target, Weight = _weightIncrement, Group = _nodeGroupMap[targetType], }, }; elements.Add(id, cy); }
/// <summary>Adds a primitive node to 'primitive'.</summary> /// <param name="elements"> The elements.</param> /// <param name="primitive">The primitive.</param> private void AddPrimitive( Dictionary <string, CytoElement> elements, FhirPrimitive primitive) { if (elements.ContainsKey(primitive.Name)) { elements[primitive.Name].Data.Weight += _weightIncrement; if (elements[primitive.Name].Data.Weight > _maxNodeWeight) { _maxNodeWeight = (decimal)elements[primitive.Name].Data.Weight; } return; } CytoElement cy = new CytoElement() { Group = CytoElement.GroupNodes, Data = new CytoElementDataNode() { Id = primitive.Name, Name = primitive.Name, Weight = _weightIncrement, Group = _nodeGroupMap[FhirNodeInfo.FhirNodeType.Primitive], }, }; elements.Add(primitive.Name, cy); TryRecurse( elements, primitive.Name, FhirNodeInfo.FhirNodeType.Primitive, primitive.BaseTypeName); }