Example #1
0
        /// <summary>
        /// Visits the children of the given payload element and replaces it with a copy if any child changes
        /// </summary>
        /// <param name="payloadElement">The payload element to potentially replace</param>
        /// <returns>The original element or a copy to replace it with</returns>
        public override ODataPayloadElement Visit(PrimitiveProperty payloadElement)
        {
            if (payloadElement.Value == null || payloadElement.Value.ClrValue == null || payloadElement.Value.IsNull)
            {
                var nullProperty = new NullPropertyInstance()
                {
                    Name = payloadElement.Name,
                };
                foreach (ODataPayloadElementAnnotation annotation in payloadElement.Annotations)
                {
                    nullProperty.Add(annotation);
                }

                return(nullProperty);
            }

            return(payloadElement);
        }