src/openSourceC.DotNetLibrary.Core/XmlSerialize.cs
/// <summary>
///		Deserializes the XML document contained by the specified <see cref="XmlReader"/>.
/// </summary>
/// <param name="type">The type of the object to deserialize.</param>
/// <param name="xmlReader">The <see cref="XmlReader"/> that contains the XML document
///		to deserialize.</param>
/// <returns>
///		An object of the specified type.
/// </returns>
Deserializes the XML document contained by the specified .
Deserializes the XML document contained by the specified .
public static object? Deserialize(Type type, XmlReader xmlReader)
		{
			if (type == null)
			{
				throw new ArgumentNullException(nameof(type));
			}
			if (xmlReader == null)
			{
				throw new ArgumentNullException(nameof(xmlReader));
			}
#if DEBUG
			try
			{
#endif
				XmlSerializer serializer = new XmlSerializer(type);
#if DIAGNOSTICS && false
				serializer.UnknownAttribute += (sender, e) =>
				{
					Debug.WriteLine($"UnknownAttribute: {e.Attr.Name} at line {e.LineNumber}, pos {e.LinePosition}");
				};
				serializer.UnknownElement += (sender, e) =>
				{
					Debug.WriteLine($"UnknownElement: {e.Element.Name} at line {e.LineNumber}, pos {e.LinePosition}";
				};
				serializer.UnreferencedObject += (sender, e) =>
				{
					Debug.WriteLine($"UnreferencedObject: ID={e.UnreferencedId}, UnreferencedObject={e.UnreferencedObject}");
				};
#endif
				return serializer.Deserialize(xmlReader);
#if DEBUG
			}
			catch (Exception)
			{
				throw;
			}
#endif
		}
public static object ? Deserialize ( Type type , XmlReader xmlReader ) { if ( type == null ) { throw new ArgumentNullException ( nameof ( type ) ) ; } if ( xmlReader == null ) { throw new ArgumentNullException ( nameof ( xmlReader ) ) ; } if DEBUG try { endif XmlSerializer serializer = new XmlSerializer ( type ) ; if DIAGNOSTICS && false serializer . UnknownAttribute += ( sender , e ) => { Debug . WriteLine ( $" UnknownAttribute:  { e . Attr . Name }  at line  { e . LineNumber } , pos  { e . LinePosition } " ) ; } ; serializer . UnknownElement += ( sender , e ) => { Debug . WriteLine ( $" UnknownElement:  { e . Element . Name }  at line  { e . LineNumber } , pos  { e . LinePosition } " ; } ; serializer . UnreferencedObject += ( sender , e ) => { Debug . WriteLine ( $" UnreferencedObject: ID= { e . UnreferencedId } , UnreferencedObject= { e . UnreferencedObject } " ) ; } ; endif return serializer . Deserialize ( xmlReader ) ; if DEBUG } catch ( Exception ) { throw ; } endif }
Deserializes the XML document contained by the specified .
Deserializes the XML document contained by the specified .
An object of the specified type.
An object of the specified type .
type
Type
The type of the object to deserialize.
The type of the object to deserialize .
xmlReader
XmlReader
The  that contains the XML document
to deserialize.
The that contains the XML document to deserialize .