Beispiel #1
0
        /// <summary>
        ///     Encodes the object specified.
        /// </summary>
        /// <param name="encoderInfo">
        ///     The encoder info.
        /// </param>
        /// <param name="value">
        ///     The object to encode.
        /// </param>
        /// <param name="writeTag">
        ///     If <c>true</c> the encoder writes the leading type tag, otherwise <c>false</c>.
        /// </param>
        internal override void Encode(EncoderInfo encoderInfo, object value, bool writeTag)
        {
            if (value != null)
            {
                var anyType = value.GetType();
                if (encoderInfo.HandleObjectRef(anyType))
                {
                    if (this.WriteOrAddObjectRef(value))
                    {
                        return;
                    }

                    var inspector       = Inspector.InspectorForType(anyType);
                    var entityReference = this.entityContext.EntityReferenceForInspector(inspector);

                    // Entity?
                    if (entityReference != null && this.SerializeEntityReference(entityReference, anyType, value))
                    {
                        return;
                    }
                }
            }

            encoderInfo.Encode(this, value, writeTag);
        }
Beispiel #2
0
        /// <summary>
        /// Encodes the object specified.
        /// </summary>
        /// <param name="encoderInfo">
        /// The encoder info.
        /// </param>
        /// <param name="value">
        /// The object to encode.
        /// </param>
        /// <param name="writeTag">
        /// If <c>true</c> the encoder writes the leading type tag, otherwise <c>false</c>.
        /// </param>
        internal override void Encode(EncoderInfo encoderInfo, object value, bool writeTag)
        {
            if (value != null)
            {
                var anyType = value.GetType();
                if (encoderInfo.HandleObjectRef(anyType))
                {
                    if (this.WriteOrAddObjectRef(value))
                    {
                        return;
                    }

                    var inspector = Inspector.InspectorForType(anyType);
                    var entityReference = this.entityContext.EntityReferenceForInspector(inspector);

                    // Entity?
                    if (entityReference != null && this.SerializeEntityReference(entityReference, anyType, value))
                    {
                        return;
                    }
                }
            }

            encoderInfo.Encode(this, value, writeTag);
        }