/// <summary>Initializes a new instance of the <see cref="FhirNodeInfo"/> class.</summary>
        /// <param name="sourceType">     Type of the source.</param>
        /// <param name="sourceNode">     Source node.</param>
        /// <param name="destinationType">The type of the edge.</param>
        /// <param name="destinationNode">Destination for the edge.</param>
        public FhirNodeInfo(
            FhirNodeType sourceType,
            object sourceNode,
            FhirNodeType destinationType,
            object destinationNode)
        {
            SourceType = sourceType;

            if (sourceNode != null)
            {
                switch (sourceType)
                {
                case FhirNodeType.Primitive:
                    _sourcePrimitive = (FhirPrimitive)sourceNode;
                    _sourceComplex   = null;
                    break;

                case FhirNodeType.DataType:
                case FhirNodeType.Resource:
                case FhirNodeType.Component:
                case FhirNodeType.Profile:
                    _sourcePrimitive = null;
                    _sourceComplex   = (FhirComplex)sourceNode;
                    break;

                case FhirNodeType.Unknown:
                case FhirNodeType.Self:
                default:
                    throw new ArgumentException($"Invalid source node type: {sourceType}");
                }
            }

            DestinationType = destinationType;

            if (destinationNode != null)
            {
                switch (destinationType)
                {
                case FhirNodeType.Primitive:
                    _destinationPrimitive = (FhirPrimitive)destinationNode;
                    _destinationComplex   = null;
                    break;

                case FhirNodeType.DataType:
                case FhirNodeType.Resource:
                case FhirNodeType.Component:
                case FhirNodeType.Profile:
                    _destinationPrimitive = null;
                    _destinationComplex   = (FhirComplex)destinationNode;
                    break;

                case FhirNodeType.Unknown:
                case FhirNodeType.Self:
                default:
                    _destinationPrimitive = null;
                    _destinationComplex   = null;
                    break;
                }
            }
        }
Example #2
0
 /// <summary>Adds a slice.</summary>
 /// <param name="sliceName">Name of the slice.</param>
 /// <param name="slice">    The slice.</param>
 internal void AddSlice(string sliceName, FhirComplex slice)
 {
     slice.SliceName = sliceName;
     _slices.Add(slice);
     _slicesByName.Add(sliceName, slice);
 }