Example #1
0
        public object GetRealObject(IObjectReference obj, string id)
        {
            object realObject = SurrogateDataContract.GetRealObject(obj, base.GetStreamingContext());

            if (realObject == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(System.Runtime.Serialization.SR.GetString("GetRealObjectReturnedNull", new object[] { DataContract.GetClrTypeFullName(obj.GetType()) })));
            }
            this.ReplaceDeserializedObject(id, obj, realObject);
            return(realObject);
        }
        public object GetRealObject(IObjectReference obj, string id)
        {
            object?realObj = SurrogateDataContract.GetRealObject(obj, this.GetStreamingContext());

            // If GetRealObject returns null, it indicates that the object could not resolve itself because
            // it is missing information. This may occur in a case where multiple IObjectReference instances
            // depend on each other. BinaryFormatter supports this by fixing up the references later. These
            // XmlObjectSerializer implementations do not support fix-ups since the format does not contain
            // forward references. However, we throw for this case since it allows us to add fix-up support
            // in the future if we need to.
            if (realObj == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException("error"));
            }
            ReplaceDeserializedObject(id, obj, realObj);
            return(realObj);
        }