internal virtual bool OnHandleReference(XmlWriterDelegator xmlWriter, object obj, bool canContainCyclicReference)
 {
     if (xmlWriter.depth < depthToCheckCyclicReference)
     {
         return(false);
     }
     if (canContainCyclicReference)
     {
         if (_byValObjectsInScope.Contains(obj))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.CannotSerializeObjectWithCycles, DataContract.GetClrTypeFullName(obj.GetType()))));
         }
         _byValObjectsInScope.Push(obj);
     }
     return(false);
 }
Exemple #2
0
 internal virtual bool OnHandleReference(XmlWriterDelegator xmlWriter, object obj, bool canContainCyclicReference)
 {
     if (xmlWriter.depth < depthToCheckCyclicReference)
     {
         return(false);
     }
     if (canContainCyclicReference)
     {
         if (byValObjectsInScope.Count == 0 && DiagnosticUtility.ShouldTraceWarning)
         {
             TraceUtility.Trace(TraceEventType.Warning, TraceCode.ObjectWithLargeDepth, SR.GetString(SR.TraceCodeObjectWithLargeDepth));
         }
         if (byValObjectsInScope.Contains(obj))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.CannotSerializeObjectWithCycles, DataContract.GetClrTypeFullName(obj.GetType()))));
         }
         byValObjectsInScope.Push(obj);
     }
     return(false);
 }