/// <summary>Deserializes an intermediate XML file into a managed object.</summary>
        /// <param name="input">Intermediate XML file.</param>
        /// <param name="referenceRelocationPath">Final name of the output file used to relative encode external reference filenames.</param>
        public static T Deserialize <T>(XmlReader input, string referenceRelocationPath)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            Uri baseUri = IntermediateSerializer.RelocationPathToUri(referenceRelocationPath);
            IntermediateReader intermediateReader = new IntermediateReader(IntermediateSerializer.SingletonInstance, input, baseUri);
            T result;

            try
            {
                if (!intermediateReader.MoveToElement("XnaContent"))
                {
                    throw intermediateReader.CreateInvalidContentException(Resources.NotIntermediateXml, new object[0]);
                }
                input.ReadStartElement();
                T t = intermediateReader.ReadObject <T>(new ContentSerializerAttribute
                {
                    ElementName = "Asset"
                });
                intermediateReader.ReadSharedResources();
                intermediateReader.ReadExternalReferences();
                input.ReadEndElement();
                result = t;
            }
            catch (XmlException ex)
            {
                throw intermediateReader.CreateInvalidContentException(ex, Resources.XmDeserializelException, new object[]
                {
                    ex.Message
                });
            }
            catch (FormatException ex2)
            {
                throw intermediateReader.CreateInvalidContentException(ex2, Resources.XmDeserializelException, new object[]
                {
                    ex2.Message
                });
            }
            catch (OverflowException ex3)
            {
                throw intermediateReader.CreateInvalidContentException(ex3, Resources.XmDeserializelException, new object[]
                {
                    ex3.Message
                });
            }
            catch (ArgumentException ex4)
            {
                throw intermediateReader.CreateInvalidContentException(ex4, Resources.XmDeserializelException, new object[]
                {
                    ex4.Message
                });
            }
            return(result);
        }
        /// <summary>Serializes an object into an intermediate XML file.</summary>
        /// <param name="output">The output XML stream.</param>
        /// <param name="value">The object to be serialized.</param>
        /// <param name="referenceRelocationPath">Final name of the output file, used to relative encode external reference filenames.</param>
        public static void Serialize <T>(XmlWriter output, T value, string referenceRelocationPath)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            Uri baseUri = IntermediateSerializer.RelocationPathToUri(referenceRelocationPath);
            IntermediateWriter intermediateWriter = new IntermediateWriter(IntermediateSerializer.SingletonInstance, output, baseUri);

            output.WriteStartElement("XnaContent");
            new XmlNamespaces(intermediateWriter).WriteNamespaces(value);
            ContentSerializerAttribute contentSerializerAttribute = new ContentSerializerAttribute();

            contentSerializerAttribute.ElementName = "Asset";
            intermediateWriter.WriteObject <object>(value, contentSerializerAttribute);
            intermediateWriter.WriteSharedResources();
            intermediateWriter.WriteExternalReferences();
            output.WriteEndElement();
        }