Beispiel #1
0
        /// <summary>
        ///     Writes the specified property.
        /// </summary>
        /// <param name="serializer">
        ///     The serializer.
        /// </param>
        /// <param name="inspectedProperty">
        ///     The inspected property.
        /// </param>
        /// <param name="any">
        ///     The object to which the property belongs.
        /// </param>
        private static void WriteProperty(Serializer serializer, InspectedProperty inspectedProperty, object any)
        {
            var value = inspectedProperty.Getter(any);

            if (value == null)
            {
                Encoder.WriteTag(serializer.BinaryWriter, Tags.Null);
            }
            else
            {
                serializer.Write(inspectedProperty.PropertyType, value.GetType(), value);
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Encodes the specified property.
        /// </summary>
        /// <param name="serializer">
        ///     The serializer.
        /// </param>
        /// <param name="inspectedProperty">
        ///     The inspected property.
        /// </param>
        /// <param name="encoderInfo">
        ///     The encoder info.
        /// </param>
        /// <param name="any">
        ///     The object to which the property belongs.
        /// </param>
        private static void EncodeProperty(Serializer serializer, InspectedProperty inspectedProperty,
                                           EncoderInfo encoderInfo, object any)
        {
            var value = inspectedProperty.Getter(any);

            if (value == null)
            {
                Encoder.WriteTag(serializer.BinaryWriter, Tags.Null);
            }
            else
            {
                serializer.Encode(encoderInfo, value, true);
            }
        }