Exemple #1
0
        /// <summary>
        /// Append an Ion value to this datagram.
        /// </summary>
        private void AppendValue(IonValue value)
        {
            if (_annotations.Count > 0)
            {
                value.ClearAnnotations();
                foreach (var annotation in _annotations)
                {
                    value.AddTypeAnnotation(annotation);
                }

                _annotations.Clear();
            }

            if (IsInStruct)
            {
                var field = AssumeFieldNameSymbol();
                ClearFieldName();
                if (field == default)
                {
                    throw new InvalidOperationException("Field name is missing");
                }

                var structContainer = _currentContainer as IonStruct;
                Debug.Assert(structContainer != null);
                structContainer.Add(field, value);
            }
            else
            {
                _currentContainer.Add(value);
            }
        }